[*] Core: Image covers is now multishop
This commit is contained in:
@@ -109,6 +109,7 @@
|
||||
var come_from = '{$table}';
|
||||
var success_add = '{l s='image has been successfully added'}';
|
||||
var id_tmp = 0;
|
||||
var current_shop_id = {$current_shop_id|intval};
|
||||
{literal}
|
||||
//Ready Function
|
||||
$(document).ready(function(){
|
||||
@@ -253,6 +254,11 @@
|
||||
$(this).attr("src", $(this).attr("src").replace("enabled", "forbbiden"));
|
||||
});
|
||||
$(this).attr("src", $(this).attr("src").replace("forbbiden", "enabled"));
|
||||
|
||||
if (current_shop_id != 0)
|
||||
$('#'+current_shop_id+id).attr('check', true);
|
||||
else
|
||||
$(this).parent().parent().parent().children('td input').attr('check', true);
|
||||
doAdminAjax({
|
||||
"action":"UpdateCover",
|
||||
"id_image":id,
|
||||
|
||||
+5
-4
@@ -618,10 +618,11 @@ class CartCore extends ObjectModel
|
||||
if (!isset($row['pai_id_image']) || $row['pai_id_image'] == 0)
|
||||
{
|
||||
$row2 = Db::getInstance()->getRow('
|
||||
SELECT i.`id_image`, il.`legend`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
|
||||
WHERE i.`id_product` = '.(int)$row['id_product'].' AND i.`cover` = 1'
|
||||
SELECT image_shop.`id_image` id_image, il.`legend`
|
||||
FROM `'._DB_PREFIX_.'image` i'.
|
||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
|
||||
WHERE i.`id_product` = '.(int)$row['id_product'].' AND image_shop.`cover` = 1'
|
||||
);
|
||||
|
||||
if (!$row2)
|
||||
|
||||
+13
-8
@@ -66,7 +66,7 @@ class ImageCore extends ObjectModel
|
||||
'fields' => array(
|
||||
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
|
||||
'cover' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'cover' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'shop' => true),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -185,12 +185,17 @@ class ImageCore extends ObjectModel
|
||||
|
||||
if (file_exists(_PS_TMP_IMG_DIR_.'product_'.$id_product.'.jpg'))
|
||||
unlink(_PS_TMP_IMG_DIR_.'product_'.$id_product.'.jpg');
|
||||
|
||||
return Db::getInstance()->execute('
|
||||
|
||||
return (Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'image`
|
||||
SET `cover` = 0
|
||||
WHERE `id_product` = '.(int)$id_product
|
||||
);
|
||||
) &&
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'image` i, `'._DB_PREFIX_.'image_shop` image_shop
|
||||
SET image_shop.`cover` = 0
|
||||
WHERE image_shop.id_shop IN ('.implode(',', array_map('intval', Shop::getContextListShopID())).') AND image_shop.id_image = i.id_image AND i.`id_product` = '.(int)$id_product
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,10 +207,10 @@ class ImageCore extends ObjectModel
|
||||
public static function getCover($id_product)
|
||||
{
|
||||
return Db::getInstance()->getRow('
|
||||
SELECT * FROM `'._DB_PREFIX_.'image`
|
||||
WHERE `id_product` = '.(int)$id_product.'
|
||||
AND `cover`= 1
|
||||
');
|
||||
SELECT * FROM `'._DB_PREFIX_.'image` i
|
||||
WHERE `id_product` = '.(int)$id_product.
|
||||
Shop::addSqlAssociation('image', 'i').'
|
||||
AND image_shop.`cover`= 1');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+9
-5
@@ -126,13 +126,14 @@ class PackCore extends Product
|
||||
if (!Pack::isFeatureActive())
|
||||
return array();
|
||||
|
||||
$sql = 'SELECT p.*, product_shop.*, pl.*, i.`id_image`, il.`legend`, t.`rate`, cl.`name` AS category_default, a.quantity AS pack_quantity, product_shop.`id_category_default`, a.id_product_pack
|
||||
$sql = 'SELECT p.*, product_shop.*, pl.*, image_shop.`id_image`, il.`legend`, t.`rate`, cl.`name` AS category_default, a.quantity AS pack_quantity, product_shop.`id_category_default`, a.id_product_pack
|
||||
FROM `'._DB_PREFIX_.'pack` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = a.id_product_item
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.id_product = pl.id_product
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
@@ -144,6 +145,7 @@ class PackCore extends Product
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE product_shop.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
AND a.`id_product_pack` = '.(int)$id_product;
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
if (!$full)
|
||||
@@ -170,11 +172,12 @@ class PackCore extends Product
|
||||
return array();
|
||||
|
||||
$sql = '
|
||||
SELECT p.*, product_shop.*, pl.*, i.`id_image`, il.`legend`, t.`rate`
|
||||
SELECT p.*, product_shop.*, pl.*, image_shop.`id_image`, il.`legend`, t.`rate`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
NATURAL LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (product_shop.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)Context::getContext()->country->id.'
|
||||
@@ -183,7 +186,8 @@ class PackCore extends Product
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE pl.`id_lang` = '.(int)$id_lang.'
|
||||
'.Shop::addSqlRestrictionOnLang('pl').'
|
||||
AND p.`id_product` IN ('.$packs.')';
|
||||
AND p.`id_product` IN ('.$packs.')
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))';
|
||||
if ($limit)
|
||||
$sql .= ' LIMIT '.(int)$limit;
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
@@ -77,7 +77,7 @@ class ProductSaleCore
|
||||
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
|
||||
pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
|
||||
m.`name` AS manufacturer_name, p.`id_manufacturer` as id_manufacturer,
|
||||
i.`id_image`, il.`legend`,
|
||||
image_shop.`id_image`, il.`legend`,
|
||||
ps.`quantity` AS sales, t.`rate`, pl.`meta_keywords`, pl.`meta_title`, pl.`meta_description`,
|
||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(),
|
||||
INTERVAL '.$interval.' DAY)) > 0 AS new
|
||||
@@ -87,7 +87,8 @@ class ProductSaleCore
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (product_shop.`id_tax_rules_group` = tr.`id_tax_rules_group`)
|
||||
@@ -102,6 +103,7 @@ class ProductSaleCore
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
ORDER BY `'.pSQL($order_by).'` '.pSQL($order_way).'
|
||||
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;
|
||||
|
||||
@@ -132,7 +134,7 @@ class ProductSaleCore
|
||||
$groups = FrontController::getCurrentCustomerGroups();
|
||||
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
|
||||
|
||||
$sql = 'SELECT p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, i.`id_image`, il.`legend`,
|
||||
$sql = 'SELECT p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, image_shop.`id_image`, il.`legend`,
|
||||
ps.`quantity` AS sales, p.`ean13`, p.`upc`, cl.`link_rewrite` AS category
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product`
|
||||
@@ -140,7 +142,8 @@ class ProductSaleCore
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON cl.`id_category` = product_shop.`id_category_default`
|
||||
@@ -152,6 +155,7 @@ class ProductSaleCore
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
ORDER BY sales DESC
|
||||
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;
|
||||
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
|
||||
|
||||
+12
-6
@@ -284,7 +284,7 @@ class SearchCore
|
||||
$alias = 'product_shop.';
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
|
||||
pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
|
||||
tax.`rate`, i.`id_image`, il.`legend`, m.`name` manufacturer_name '.$score.',
|
||||
tax.`rate`, image_shop.`id_image`, il.`legend`, m.`name` manufacturer_name '.$score.',
|
||||
DATEDIFF(
|
||||
p.`date_add`,
|
||||
DATE_SUB(
|
||||
@@ -303,10 +303,12 @@ class SearchCore
|
||||
AND tr.`id_state` = 0)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax` tax ON (tax.`id_tax` = tr.`id_tax`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
'.Product::sqlStock('p', 0).'
|
||||
WHERE p.`id_product` '.$product_pool.'
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
'.($order_by ? 'ORDER BY '.$alias.$order_by : '').($order_way ? ' '.$order_way : '').'
|
||||
LIMIT '.(int)(($page_number - 1) * $page_size).','.(int)$page_size;
|
||||
$result = $db->executeS($sql);
|
||||
@@ -323,9 +325,11 @@ class SearchCore
|
||||
AND tr.`id_state` = 0)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax` tax ON (tax.`id_tax` = tr.`id_tax`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE p.`id_product` '.$product_pool;
|
||||
WHERE p.`id_product` '.$product_pool.'
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))';
|
||||
$total = $db->getValue($sql);
|
||||
|
||||
if (!$result)
|
||||
@@ -632,7 +636,7 @@ class SearchCore
|
||||
}
|
||||
|
||||
$sql = 'SELECT DISTINCT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description_short`, pl.`link_rewrite`, pl.`name`,
|
||||
tax.`rate`, i.`id_image`, il.`legend`, m.`name` manufacturer_name, 1 position,
|
||||
tax.`rate`, image_shop.`id_image`, il.`legend`, m.`name` manufacturer_name, 1 position,
|
||||
DATEDIFF(
|
||||
p.`date_add`,
|
||||
DATE_SUB(
|
||||
@@ -646,7 +650,8 @@ class SearchCore
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
'.Shop::addSqlAssociation('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (product_shop.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)$context->country->id.'
|
||||
@@ -665,6 +670,7 @@ class SearchCore
|
||||
SELECT id_group FROM '._DB_PREFIX_.'customer_group
|
||||
WHERE id_customer = '.(int)$id_customer.')').'
|
||||
AND t.`name` LIKE \'%'.pSQL($tag).'%\'
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
ORDER BY position DESC'.($orderBy ? ', '.$orderBy : '').($orderWay ? ' '.$orderWay : '').'
|
||||
LIMIT '.(int)(($pageNumber - 1) * $pageSize).','.(int)$pageSize;
|
||||
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
|
||||
|
||||
@@ -253,7 +253,7 @@ class SupplierCore extends ObjectModel
|
||||
pl.`meta_keywords`,
|
||||
pl.`meta_title`,
|
||||
pl.`name`,
|
||||
i.`id_image`,
|
||||
image_shop.`id_image`,
|
||||
il.`legend`,
|
||||
s.`name` AS supplier_name,
|
||||
tl.`name` AS tax_name,
|
||||
@@ -267,8 +267,8 @@ class SupplierCore extends ObjectModel
|
||||
AND ps.id_product_attribute = 0)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`
|
||||
AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
|
||||
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image`
|
||||
AND il.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (product_shop.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
@@ -291,6 +291,7 @@ class SupplierCore extends ObjectModel
|
||||
($active_category ? ' INNER JOIN `'._DB_PREFIX_.'category` ca ON cp.`id_category` = ca.`id_category` AND ca.`active` = 1' : '').'
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
ORDER BY '.$alias.pSQL($order_by).' '.pSQL($order_way).'
|
||||
LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;
|
||||
|
||||
|
||||
@@ -215,9 +215,9 @@ class OrderInvoiceCore extends ObjectModel
|
||||
if (!isset($image['id_image']) || !$image['id_image'])
|
||||
$id_image = Db::getInstance()->getValue('
|
||||
SELECT id_image
|
||||
FROM '._DB_PREFIX_.'image
|
||||
WHERE id_product = '.(int)($product['product_id']).' AND cover = 1
|
||||
');
|
||||
FROM '._DB_PREFIX_.'image'.
|
||||
Shop::addSqlAssociation('image', 'i', true, 'image_shop.cover=1').'
|
||||
WHERE id_product = '.(int)($product['product_id']));
|
||||
|
||||
$product['image'] = null;
|
||||
$product['image_size'] = null;
|
||||
|
||||
@@ -215,35 +215,41 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (Validate::isLoadedObject($this->_category) && empty($this->_filter))
|
||||
$join_category = true;
|
||||
|
||||
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product`)';
|
||||
if (Shop::isFeatureActive())
|
||||
{
|
||||
$alias = 'sa';
|
||||
$alias_image = 'image_shop';
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP)
|
||||
$this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.(int)$this->context->shop->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.(int)$this->context->shop->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.(int)$this->context->shop->id.') ';
|
||||
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.(int)$this->context->shop->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop='.(int)$this->context->shop->id.')';
|
||||
else
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = a.id_shop_default)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = a.id_shop_default)
|
||||
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = a.id_shop_default) ';
|
||||
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = a.id_shop_default)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop=a.id_shop_default)';
|
||||
$this->_select .= 'shop.name as shopname, ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$alias = 'a';
|
||||
$alias_image = 'i';
|
||||
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = 1)';
|
||||
}
|
||||
|
||||
$this->_join .= '
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1)
|
||||
'.($join_category ? 'INNER JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product` AND cp.`id_category` = '.(int)$this->_category->id.')' : '').'
|
||||
$this->_join .= ($join_category ? 'INNER JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product` AND cp.`id_category` = '.(int)$this->_category->id.')' : '').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON ('.$alias.'.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$this->context->country->id.' AND tr.`id_state` = 0)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.`id_product` = a.`id_product` AND sav.`id_product_attribute` = 0
|
||||
'.StockAvailable::addSqlShopRestriction(null, null, 'sav').') ';
|
||||
$this->_select .= 'cl.name `name_category` '.($join_category ? ', cp.`position`' : '').', '.$alias_image.'.`id_image`, '.$alias.'.`price`, ('.$alias.'.`price` * ((100 + (t.`rate`))/100)) AS price_final, sav.`quantity` as sav_quantity, '.$alias.'.`active`';
|
||||
|
||||
$this->_select .= 'cl.name `name_category` '.($join_category ? ', cp.`position`' : '').', i.`id_image`, '.$alias.'.`price`, ('.$alias.'.`price` * ((100 + (t.`rate`))/100)) AS price_final, sav.`quantity` as sav_quantity, '.$alias.'.`active`';
|
||||
|
||||
if (Shop::isFeatureActive())
|
||||
$this->_where .= ' AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))';
|
||||
else
|
||||
$this->_where .= ' AND i.cover=1';
|
||||
}
|
||||
protected function _cleanMetaKeywords($keywords)
|
||||
{
|
||||
@@ -1398,7 +1404,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
$res &= Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'image`
|
||||
SET `cover` = 1
|
||||
WHERE `id_product` = '.(int)$image->id_product.' LIMIT 1');
|
||||
WHERE `id_product` = '.(int)$image->id_product.'
|
||||
AND id_shop='.(int)$this->context->shop->id.'
|
||||
LIMIT 1');
|
||||
}
|
||||
|
||||
if (file_exists(_PS_TMP_IMG_DIR_.'product_'.$image->id_product.'.jpg'))
|
||||
@@ -3426,23 +3434,29 @@ class AdminProductsControllerCore extends AdminController
|
||||
FROM '._DB_PREFIX_.'image
|
||||
WHERE id_product = '.(int)$obj->id
|
||||
);
|
||||
$data->assign('countImages', $count_images);
|
||||
|
||||
|
||||
$images = Image::getImages($this->context->language->id, $obj->id);
|
||||
$data->assign('id_product', (int)Tools::getValue('id_product'));
|
||||
$data->assign('id_category_default', (int)$this->_category->id);
|
||||
|
||||
foreach ($images as $k => $image)
|
||||
$images[$k] = new Image($image['id_image']);
|
||||
|
||||
$data->assign('images', $images);
|
||||
|
||||
$data->assign('token', $this->token);
|
||||
$data->assign('table', $this->table);
|
||||
$data->assign('max_image_size', $this->max_image_size / 1024 / 1024);
|
||||
|
||||
$data->assign('up_filename', strval(Tools::getValue('virtual_product_filename_attribute')));
|
||||
$data->assign('currency', $this->context->currency);
|
||||
if ($this->context->shop->getContext() == Shop::CONTEXT_SHOP)
|
||||
$current_shop_id = (int)$this->context->shop->id;
|
||||
else
|
||||
$current_shop_id = 0;
|
||||
|
||||
$data->assign(array(
|
||||
'countImages' => $count_images,
|
||||
'id_product' => (int)Tools::getValue('id_product'),
|
||||
'id_category_default' => (int)$this->_category->id,
|
||||
'images' => $images,
|
||||
'token' => $this->token,
|
||||
'table' => $this->table,
|
||||
'max_image_size' => $this->max_image_size / 1024 / 1024,
|
||||
'up_filename' => (string)Tools::getValue('virtual_product_filename_attribute'),
|
||||
'currency' => $this->context->currency,
|
||||
'current_shop_id' => $current_shop_id
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
$this->displayWarning($this->l('You must save this product in this shop before adding images.'));
|
||||
|
||||
@@ -2032,9 +2032,10 @@ CREATE TABLE `PREFIX_contact_shop` (
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_image_shop` (
|
||||
`id_image` INT( 11 ) UNSIGNED NOT NULL,
|
||||
`id_shop` INT( 11 ) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id_image`, `id_shop`),
|
||||
`id_image` INT( 11 ) UNSIGNED NOT NULL,
|
||||
`id_shop` INT( 11 ) UNSIGNED NOT NULL,
|
||||
`cover` tinyint(1) NOT NULL,
|
||||
PRIMARY KEY (`id_image`, `id_shop`, `cover`),
|
||||
KEY `id_shop` (`id_shop`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
SET NAMES 'utf8';
|
||||
|
||||
ALTER TABLE `PREFIX_image_shop` ADD `cover` TINYINT(1) UNSIGNED NOT NULL AFTER `id_shop`;
|
||||
ALTER TABLE `PREFIX_image_shop` DROP PRIMARY KEY;
|
||||
ALTER TABLE `PREFIX_image_shop` ADD PRIMARY KEY (`id_image`, `id_shop`, `cover`);
|
||||
Reference in New Issue
Block a user