diff --git a/admin-dev/themes/default/css/admin.css b/admin-dev/themes/default/css/admin.css index 68ee2eb4a..d7f5b3633 100644 --- a/admin-dev/themes/default/css/admin.css +++ b/admin-dev/themes/default/css/admin.css @@ -18,6 +18,7 @@ fieldset{background-color:#EBEDF4; border:1px solid #CCCED7; color:#585A69; font .Bloc {background-color:#EBEDF4; border:1px solid #CCCED7;font-size:1.1em;margin:0;padding:1em} legend{background:#EBEDF4;border:1px solid #CCCED7;font-weight:700;margin:0;padding:.2em .5em;text-align:left} input[type="text"],input[type="password"],input[type="file"],textarea {border:1px solid #ccc; background-color:#fff;} +input[type="text"]:disabled,input[type="password"]:disabled,input[type="file"]:disabled,textarea:disabled {border:1px solid #ccc; background-color:#dedede; color: #444444;} select { border:1px solid #ccc; font-size: 12px;} select[disabled="disabled"], input[disabled="disabled"],textarea[disabled="disabled"], option[disabled="disabled"] {border: 1px solid #CCCCCC;color: #AAAAAA} .header_module{background:url('../img/header_module.png');padding-left: 0.5em;padding-top: 0.8em;height:20px;color: #812143;border:solid 1px #CCC;} @@ -182,9 +183,9 @@ a.module_toggle_all{color: #268CCD;} .multishop_toolbar select.shopList { width: 300px; } .multishop_toolbar a.chzn-single { background: url('../img/icon-multishop.png') no-repeat 5px 5px; padding: 1px 2px 2px 25px; font-weight: bold; } -.multishop_toolbar .chzn-container .first{font-weight: bold;background-color: #408BD5;color: #ffffff;} -.multishop_toolbar .chzn-container .group{font-weight: bold;font-style: italic;padding-left: 15px;background-color: #C6DEFC;} -.multishop_toolbar .chzn-container .shop{padding-left: 30px;background-color: #EAF2FC;} +.multishop_toolbar .chzn-container .chzn-results .first{font-weight: bold;background-color: #408BD5;color: #ffffff;} +.multishop_toolbar .chzn-container .chzn-results .group{font-weight: bold;font-style: italic;padding-left: 15px;background-color: #C6DEFC;} +.multishop_toolbar .chzn-container .chzn-results .shop{padding-left: 30px;background-color: #EAF2FC;} /*toolbarBox*/ .toolbarBox { background-color: #F8F8F8; border: 1px solid #CCCCCC; margin-bottom:10px; padding: 10px 0; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px;} diff --git a/admin-dev/themes/default/img/bullet_orange.png b/admin-dev/themes/default/img/bullet_orange.png new file mode 100644 index 000000000..456774e9d Binary files /dev/null and b/admin-dev/themes/default/img/bullet_orange.png differ diff --git a/admin-dev/themes/default/template/controllers/attributes/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/attributes/helpers/form/form.tpl index d65e244b6..571ecfe9e 100644 --- a/admin-dev/themes/default/template/controllers/attributes/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/attributes/helpers/form/form.tpl @@ -69,10 +69,10 @@ var changeAssociationGroup = function() { var id_attribute_group = $('#id_attribute_group').val(); - $('.input_group_shop').each(function(k, item) + $('.input_shop_group').each(function(k, item) { - var id_group_shop = $(item).val(); - if (typeof shop_associations[id_attribute_group] != 'undefined' && $.inArray(id_group_shop, shop_associations[id_attribute_group]) > -1) + var id_shop_group = $(item).val(); + if (typeof shop_associations[id_attribute_group] != 'undefined' && $.inArray(id_shop_group, shop_associations[id_attribute_group]) > -1) $(item).attr('disabled', false); else { diff --git a/admin-dev/themes/default/template/controllers/products/associations.tpl b/admin-dev/themes/default/template/controllers/products/associations.tpl index fa8c43b5a..4dbfa2b49 100644 --- a/admin-dev/themes/default/template/controllers/products/associations.tpl +++ b/admin-dev/themes/default/template/controllers/products/associations.tpl @@ -66,12 +66,6 @@ - {if $feature_shop_active} -
- {* @todo use asso_shop from Helper *} - - {$displayAssoShop} - {/if}
diff --git a/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl index 3a41d9315..fce48bbe1 100644 --- a/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl @@ -40,9 +40,19 @@ theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "styleprops,|,cite,abbr,acronym,del,ins,attribs,pagebreak", setup : function(ed) { - {* Count the total number of the field *} + ed.onInit.add(function(ed) + { + if (typeof load_tinymce_multishop[ed.id] != 'undefined') + { + if (typeof load_tinymce_multishop[ed.id]) + ed.hide(); + else + ed.show(); + } + }); + ed.onKeyUp.add(function(ed, e) { tinyMCE.triggerSave(); textarea = $('#'+ed.id); @@ -94,8 +104,12 @@ var save_error = {if $save_error}true{else}false{/if}; var product_type = {$product_type}; - {*var mce_maximum = '{l s='Maximum'}'; - var mce_characters = '{l s='characters'}';*} + {*var mce_maximum = '{l s='Maximum'}';*} + {if isset($display_multishop_checkboxes) && $display_multishop_checkboxes} + var display_multishop_checkboxes = true; + {else} + var display_multishop_checkboxes = false; + {/if} $(document).ready(function() { diff --git a/admin-dev/themes/default/template/controllers/products/informations.tpl b/admin-dev/themes/default/template/controllers/products/informations.tpl index 039c30abf..aef0feab4 100644 --- a/admin-dev/themes/default/template/controllers/products/informations.tpl +++ b/admin-dev/themes/default/template/controllers/products/informations.tpl @@ -23,18 +23,74 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - +{if $check_product_association_ajax} +{assign var=class_input_ajax value='check_product_name '} +{else} +{assign var=class_input_ajax value=''} +{/if}

1. {l s='Info.'}

{l s='Product global information'}

+ + {if isset($display_common_field) && $display_common_field} +
{l s='Warning, if you change the value of fields with an orange bullet %s, the value will be changed for all other shops for this product' sprintf=$bullet_common_field}
+ {/if} + + {include file="controllers/products/multishop/check_fields.tpl" product_tab="Informations"} +
- + @@ -48,35 +104,37 @@
{* global information *} - + - + - + - + @@ -86,6 +144,7 @@
+ {include file="controllers/products/multishop/checkbox.tpl" field="name" type="default" multilang="true"} + + {foreach from=$languages item=language}
- id}disabled="disabled"{/if} + id}disabled="disabled"{/if} id="name_{$language.id_lang}" name="name_{$language.id_lang}" value="{$product->name[$language.id_lang]|htmlentitiesUTF8|default:''}"/> * {l s='Invalid characters:'} <>;=#{} 
{/foreach} -
{l s='Special characters allowed:'}.-_#\ 
{l s='(Europe, Japan)'}
{l s='(US, Canada)'}
- + active}style="display:none"{/if} > - + - + -
+ {include file="controllers/products/multishop/checkbox.tpl" field="active" type="radio" onclick=""} @@ -102,7 +161,10 @@
+ {include file="controllers/products/multishop/checkbox.tpl" field="visibility" type="default"} + +
+ {if isset($display_multishop_checkboxes) && $display_multishop_checkboxes} +
+
    +
  • {include file="controllers/products/multishop/checkbox.tpl" only_checkbox="true" field="available_for_order" type="default"}
  • +
  • {include file="controllers/products/multishop/checkbox.tpl" only_checkbox="true" field="show_price" type="show_price"}
  • +
  • {include file="controllers/products/multishop/checkbox.tpl" only_checkbox="true" field="online_only" type="default"}
  • +
+
+ {/if} + + +
  • @@ -128,10 +202,14 @@ online_only}checked="checked"{/if} />
  • +
+ {include file="controllers/products/multishop/checkbox.tpl" field="condition" type="default"} + +
- + - +

({l s='appears in the product lists and on the top of the product page'})

+ {include file="controllers/products/multishop/checkbox.tpl" field="description_short" type="tinymce" multilang="true"} + +

({l s='appears in the product lists and on the top of the product page'})

+
{include file="controllers/products/textarea_lang.tpl" languages=$languages @@ -157,7 +238,11 @@

({l s='appears in the body of the product page'})

+ {include file="controllers/products/multishop/checkbox.tpl" field="description" type="tinymce" multilang="true"} + +

({l s='appears in the body of the product page'})

+
{include file="controllers/products/textarea_lang.tpl" languages=$languages input_name='description' @@ -257,4 +342,3 @@

- diff --git a/admin-dev/themes/default/template/controllers/products/multishop/check_fields.tpl b/admin-dev/themes/default/template/controllers/products/multishop/check_fields.tpl new file mode 100644 index 000000000..d3e34b435 --- /dev/null +++ b/admin-dev/themes/default/template/controllers/products/multishop/check_fields.tpl @@ -0,0 +1,32 @@ +{* +* 2007-2012 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2012 PrestaShop SA +* @version Release: $Revision: 9856 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{if isset($display_multishop_checkboxes) && $display_multishop_checkboxes} + +{/if} \ No newline at end of file diff --git a/admin-dev/themes/default/template/controllers/products/multishop/checkbox.tpl b/admin-dev/themes/default/template/controllers/products/multishop/checkbox.tpl new file mode 100644 index 000000000..b5463ced5 --- /dev/null +++ b/admin-dev/themes/default/template/controllers/products/multishop/checkbox.tpl @@ -0,0 +1,51 @@ +{* +* 2007-2012 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2012 PrestaShop SA +* @version Release: $Revision: 9856 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{if isset($display_multishop_checkboxes) && $display_multishop_checkboxes} + {if isset($multilang) && $multilang} + {if isset($only_checkbox)} + {foreach from=$languages item=language} + + {/foreach} + {else} +
+ {foreach from=$languages item=language} +
+ +
+ {/foreach} +
+ {/if} + {else} + {if isset($only_checkbox)} + + {else} +
+ +
+ {/if} + {/if} +{/if} \ No newline at end of file diff --git a/admin-dev/themes/default/template/controllers/products/prices.tpl b/admin-dev/themes/default/template/controllers/products/prices.tpl index 71627a5d7..def8fed5f 100644 --- a/admin-dev/themes/default/template/controllers/products/prices.tpl +++ b/admin-dev/themes/default/template/controllers/products/prices.tpl @@ -106,18 +106,27 @@ jQuery(document).ready(Customer.init);
{l s='You must enter either the pre-tax retail price, or the retail price with tax. The input field will be automatically calculated.'}
+ +{include file="controllers/products/multishop/check_fields.tpl" product_tab="Price"} +
- + - + - +
+ {include file="controllers/products/multishop/checkbox.tpl" field="wholesale_price" type="default"} + + - {$currency->prefix}{$currency->suffix} + {$currency->prefix}{$currency->suffix}

{l s='The wholesale price at which you bought this product'}

+ {include file="controllers/products/multishop/checkbox.tpl" field="price" type="price"} + + {$currency->prefix}{$currency->suffix} @@ -125,7 +134,10 @@ jQuery(document).ready(Customer.init);
+ {include file="controllers/products/multishop/checkbox.tpl" field="id_tax_rules_group" type="default"} + + '; } } + } return $html; } @@ -3871,6 +3932,14 @@ class BlockLayered extends Module $db = Db::getInstance(_PS_USE_SQL_SLAVE_); $n_categories = array(); $done_categories = array(); + $alias = 'p'; + $join_product_attribute = $join_product = ''; + if (version_compare(_PS_VERSION_,'1.5','>')) + { + $alias = 'product_shop'; + $join_product = Shop::addSqlAssociation('product', 'p'); + $join_product_attribute = Shop::addSqlAssociation('product_attribute', 'pa'); + } $attribute_groups = self::query(' SELECT a.id_attribute, a.id_attribute_group @@ -3878,10 +3947,13 @@ class BlockLayered extends Module LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute) LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON (pa.id_product_attribute = pac.id_product_attribute) LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = pa.id_product) + '.$join_product.$join_product_attribute.' LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product) LEFT JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category) - WHERE c.active = 1'.(count($categories_ids) ? ' AND cp.id_category IN ('.implode(',', $categories_ids).')' : '').' AND p.active = 1'.(count($products_ids) ? ' - AND p.id_product IN ('.implode(',', $products_ids).')' : '')); + WHERE c.active = 1'. + (count($categories_ids) ? 'AND cp.id_category IN ('.implode(',', $categories_ids).')' : '').' + AND '.$alias.'.active = 1'. + (count($products_ids) ? 'AND p.id_product IN ('.implode(',', $products_ids).')' : '')); $attribute_groups_by_id = array(); while ($row = $db->nextRow($attribute_groups)) @@ -3892,10 +3964,11 @@ class BlockLayered extends Module FROM '._DB_PREFIX_.'feature_value fv LEFT JOIN '._DB_PREFIX_.'feature_product fp ON (fp.id_feature_value = fv.id_feature_value) LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = fp.id_product) + '.$join_product.' LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product) LEFT JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category) WHERE (fv.custom IS NULL OR fv.custom = 0) AND c.active = 1'.(count($categories_ids) ? ' AND cp.id_category IN ('.implode(',', $categories_ids).')' : '').' - AND p.active = 1'.(count($products_ids) ? ' AND p.id_product IN ('.implode(',', $products_ids).')' : '')); + AND '.$alias.'.active = 1'.(count($products_ids) ? ' AND p.id_product IN ('.implode(',', $products_ids).')' : '')); $features_by_id = array(); while ($row = $db->nextRow($features)) @@ -3912,9 +3985,12 @@ class BlockLayered extends Module LEFT JOIN '._DB_PREFIX_.'feature_product fp ON (fp.id_product = p.id_product) LEFT JOIN '._DB_PREFIX_.'feature_value fv ON (fv.id_feature_value = fp.id_feature_value) LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON (pa.id_product = p.id_product) + '.$join_product.$join_product_attribute.' LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = pa.id_product_attribute) - WHERE c.active = 1'.(count($categories_ids) ? ' AND cp.id_category IN ('.implode(',', $categories_ids).')' : '').' AND p.active = 1'.(count($products_ids) ? ' - AND p.id_product IN ('.implode(',', $products_ids).')' : '').' AND (fv.custom IS NULL OR fv.custom = 0) + WHERE c.active = 1'.(count($categories_ids) ? ' AND cp.id_category IN ('.implode(',', $categories_ids).')' : ''). + ' AND '.$alias.'.active = 1'. + (count($products_ids) ? ' AND p.id_product IN ('.implode(',', $products_ids).')' : ''). + ' AND (fv.custom IS NULL OR fv.custom = 0) GROUP BY p.id_product'); diff --git a/modules/blocklink/blocklink.php b/modules/blocklink/blocklink.php index 30cd6dc7a..dc95d8396 100644 --- a/modules/blocklink/blocklink.php +++ b/modules/blocklink/blocklink.php @@ -318,7 +318,8 @@ class BlockLink extends Module
*
'; - if (Shop::isFeatureActive()) + $shops = Shop::getShops(true, null, true); + if (Shop::isFeatureActive() && count($shops) > 1) { $helper = new HelperForm(); $helper->id = (int)Tools::getValue('id_link'); diff --git a/modules/blocknewsletter/blocknewsletter.php b/modules/blocknewsletter/blocknewsletter.php index 88eb201e4..8dcd53a9a 100644 --- a/modules/blocknewsletter/blocknewsletter.php +++ b/modules/blocknewsletter/blocknewsletter.php @@ -71,7 +71,7 @@ class Blocknewsletter extends Module CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'newsletter` ( `id` int(6) NOT NULL AUTO_INCREMENT, `id_shop` INTEGER UNSIGNED NOT NULL DEFAULT \'1\', - `id_group_shop` INTEGER UNSIGNED NOT NULL DEFAULT \'1\', + `id_shop_group` INTEGER UNSIGNED NOT NULL DEFAULT \'1\', `email` varchar(255) NOT NULL, `newsletter_date_add` DATETIME NULL, `ip_registration_newsletter` varchar(15) NOT NULL, @@ -312,10 +312,10 @@ class Blocknewsletter extends Module */ protected function registerGuest($email, $active = true) { - $sql = 'INSERT INTO '._DB_PREFIX_.'newsletter (id_shop, id_group_shop, email, newsletter_date_add, ip_registration_newsletter, http_referer, active) + $sql = 'INSERT INTO '._DB_PREFIX_.'newsletter (id_shop, id_shop_group, email, newsletter_date_add, ip_registration_newsletter, http_referer, active) VALUES ('.$this->context->shop->id.', - '.$this->context->shop->id_group_shop.', + '.$this->context->shop->id_shop_group.', \''.pSQL($email).'\', NOW(), \''.pSQL(Tools::getRemoteAddr()).'\', diff --git a/modules/blocknewsletter/config.xml b/modules/blocknewsletter/config.xml index c9d08d864..15b6e2ed3 100755 --- a/modules/blocknewsletter/config.xml +++ b/modules/blocknewsletter/config.xml @@ -1,12 +1,12 @@ blocknewsletter - + - + - Are you sure you want to delete all your contacts ? + Êtes-vous sûr de vouloir supprimer tous vos contacts ? 1 0 diff --git a/modules/blockviewed/blockviewed.php b/modules/blockviewed/blockviewed.php index d7a4f6549..d018b531a 100644 --- a/modules/blockviewed/blockviewed.php +++ b/modules/blockviewed/blockviewed.php @@ -102,13 +102,13 @@ class BlockViewed extends Module $productIds = implode(',', $productsViewed); $productsImages = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT i.id_image, p.id_product, il.legend, p.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite + SELECT i.id_image, p.id_product, il.legend, product_shop.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite FROM '._DB_PREFIX_.'product p LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.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_lang il ON (il.id_image = i.id_image) '.Shop::addSqlAssociation('product', 'p').' - LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = asso_shop_product.id_category_default'.Shop::addSqlRestrictionOnLang('cl').') + LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = product_shop.id_category_default'.Shop::addSqlRestrictionOnLang('cl').') WHERE p.id_product IN ('.$productIds.') AND pl.id_lang = '.(int)($params['cookie']->id_lang).' AND cl.id_lang = '.(int)($params['cookie']->id_lang) diff --git a/modules/blockwishlist/WishList.php b/modules/blockwishlist/WishList.php index a05eeb726..57f89f2d9 100644 --- a/modules/blockwishlist/WishList.php +++ b/modules/blockwishlist/WishList.php @@ -52,7 +52,7 @@ class WishList extends ObjectModel public $id_shop; /** @var string Object last modification date */ - public $id_group_shop; + public $id_shop_group; /** * @see ObjectModel::$definition */ @@ -66,7 +66,7 @@ class WishList extends ObjectModel 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), ) ); @@ -109,8 +109,8 @@ class WishList extends ObjectModel { if (Shop::getContextShopID()) $shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID(); - elseif (Shop::getContextGroupShopID()) - $shop_restriction = 'AND id_group_shop = '.(int)Shop::getContextGroupShopID(); + elseif (Shop::getContextShopGroupID()) + $shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID(); else $shop_restriction = ''; @@ -174,8 +174,8 @@ class WishList extends ObjectModel { if (Shop::getContextShopID()) $shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID(); - elseif (Shop::getContextGroupShopID()) - $shop_restriction = 'AND id_group_shop = '.(int)Shop::getContextGroupShopID(); + elseif (Shop::getContextShopGroupID()) + $shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID(); else $shop_restriction = ''; @@ -276,7 +276,7 @@ class WishList extends ObjectModel '.Shop::addSqlAssociation('product', 'p').' JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Shop::addSqlRestrictionOnLang('pl').' JOIN `'._DB_PREFIX_.'wishlist` w ON w.`id_wishlist` = wp.`id_wishlist` - LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = asso_shop_product.`id_category_default` AND cl.id_lang='.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').' + LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = product_shop.`id_category_default` AND cl.id_lang='.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').' WHERE w.`id_customer` = '.(int)($id_customer).' AND pl.`id_lang` = '.(int)($id_lang).' AND wp.`id_wishlist` = '.(int)($id_wishlist). @@ -298,6 +298,7 @@ class WishList extends ObjectModel LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)($id_lang).') LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)($id_lang).') LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pac.`id_product_attribute` = pa.`id_product_attribute`) + '.Shop::addSqlAssociation('product_attribute', 'pa').' WHERE pac.`id_product_attribute` = '.(int)($products[$i]['id_product_attribute'])); $products[$i]['attributes_small'] = ''; if ($result) @@ -322,8 +323,8 @@ class WishList extends ObjectModel { if (Shop::getContextShopID()) $shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID(); - elseif (Shop::getContextGroupShopID()) - $shop_restriction = 'AND id_group_shop = '.(int)Shop::getContextGroupShopID(); + elseif (Shop::getContextShopGroupID()) + $shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID(); else $shop_restriction = ''; diff --git a/modules/blockwishlist/cart.php b/modules/blockwishlist/cart.php index 9c00600b8..9c1b21635 100644 --- a/modules/blockwishlist/cart.php +++ b/modules/blockwishlist/cart.php @@ -54,7 +54,7 @@ if ($context->customer->isLogged()) { $wishlist = new WishList(); $wishlist->id_shop = $context->shop->id; - $wishlist->id_group_shop = $context->shop->id_group_shop; + $wishlist->id_shop_group = $context->shop->id_shop_group; $modWishlist = new BlockWishList(); $wishlist->name = $modWishlist->default_wishlist_name; diff --git a/modules/blockwishlist/controllers/front/mywishlist.php b/modules/blockwishlist/controllers/front/mywishlist.php index f51e5d6ef..fcfd69060 100644 --- a/modules/blockwishlist/controllers/front/mywishlist.php +++ b/modules/blockwishlist/controllers/front/mywishlist.php @@ -82,7 +82,7 @@ class BlockWishListMyWishListModuleFrontController extends ModuleFrontController { $wishlist = new WishList(); $wishlist->id_shop = $this->context->shop->id; - $wishlist->id_group_shop = $this->context->shop->id_group_shop; + $wishlist->id_shop_group = $this->context->shop->id_shop_group; $wishlist->name = $name; $wishlist->id_customer = (int)$this->context->customer->id; list($us, $s) = explode(' ', microtime()); diff --git a/modules/blockwishlist/install.sql b/modules/blockwishlist/install.sql index 8d0fece0e..fbcdc2e31 100644 --- a/modules/blockwishlist/install.sql +++ b/modules/blockwishlist/install.sql @@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `PREFIX_wishlist` ( `name` varchar(64) character set utf8 NOT NULL, `counter` int(10) unsigned NULL, `id_shop` int(10) unsigned default 1, - `id_group_shop` int(10) unsigned default 1, + `id_shop_group` int(10) unsigned default 1, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_wishlist`) diff --git a/modules/crossselling/crossselling.php b/modules/crossselling/crossselling.php index b78e2c2bd..246a02376 100755 --- a/modules/crossselling/crossselling.php +++ b/modules/crossselling/crossselling.php @@ -139,17 +139,22 @@ class CrossSelling extends Module $list_product_ids = join(',', $pIds); $orderProducts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, p.show_price, cl.link_rewrite category, p.ean13 - FROM '._DB_PREFIX_.'order_detail od - LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id) - '.Shop::addSqlAssociation('product', 'p').' - LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.Shop::addSqlRestrictionOnLang('pl').') - LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = asso_shop_product.id_category_default'.Shop::addSqlRestrictionOnLang('cl').') - LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id) - WHERE od.id_order IN ('.$list.') AND pl.id_lang = '.(int)$this->context->language->id.' AND cl.id_lang = '.(int)$this->context->language->id.' - AND od.product_id NOT IN ('.$list_product_ids.') AND i.cover = 1 AND p.active = 1 - ORDER BY RAND() - LIMIT 10'); + SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price, cl.link_rewrite category, p.ean13 + FROM '._DB_PREFIX_.'order_detail od + LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id) + '.Shop::addSqlAssociation('product', 'p').' + LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.Shop::addSqlRestrictionOnLang('pl').') + LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = product_shop.id_category_default'.Shop::addSqlRestrictionOnLang('cl').') + LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id) + WHERE od.id_order IN ('.$list.') + AND pl.id_lang = '.(int)$this->context->language->id.' + AND cl.id_lang = '.(int)$this->context->language->id.' + AND od.product_id NOT IN ('.$list_product_ids.') + AND i.cover = 1 + AND product_shop.active = 1 + ORDER BY RAND() + LIMIT 10 + '); $taxCalc = Product::getTaxCalculationMethod(); foreach ($orderProducts AS &$orderProduct) @@ -188,16 +193,22 @@ class CrossSelling extends Module $list = rtrim($list, ','); $orderProducts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, p.show_price, cl.link_rewrite category, p.ean13 - FROM '._DB_PREFIX_.'order_detail od - LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id) - LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.Shop::addSqlRestrictionOnLang('pl').') - LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.Shop::addSqlRestrictionOnLang('cl').') - LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id) - WHERE od.id_order IN ('.$list.') AND pl.id_lang = '.(int)$this->context->language->id.' AND cl.id_lang = '.(int)$this->context->language->id.' - AND od.product_id != '.(int)$params['product']->id.' AND i.cover = 1 AND p.active = 1 - ORDER BY RAND() - LIMIT 10'); + SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price, cl.link_rewrite category, p.ean13 + FROM '._DB_PREFIX_.'order_detail od + LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id) + '.Shop::addSqlAssociation('product', 'p').' + LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.Shop::addSqlRestrictionOnLang('pl').') + LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = product_shop.id_category_default'.Shop::addSqlRestrictionOnLang('cl').') + LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id) + WHERE od.id_order IN ('.$list.') + AND pl.id_lang = '.(int)$this->context->language->id.' + AND cl.id_lang = '.(int)$this->context->language->id.' + AND od.product_id != '.(int)$params['product']->id.' + AND i.cover = 1 + AND product_shop.active = 1 + ORDER BY RAND() + LIMIT 10 + '); $taxCalc = Product::getTaxCalculationMethod(); foreach ($orderProducts AS &$orderProduct) diff --git a/modules/favoriteproducts/FavoriteProduct.php b/modules/favoriteproducts/FavoriteProduct.php index 8207c945d..76aa2e2cd 100644 --- a/modules/favoriteproducts/FavoriteProduct.php +++ b/modules/favoriteproducts/FavoriteProduct.php @@ -61,14 +61,17 @@ class FavoriteProduct extends ObjectModel pl.`name`, i.`id_image`, CONCAT(p.`id_product`, \'-\', i.`id_image`) as image FROM `'._DB_PREFIX_.'favorite_product` fp LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = fp.`id_product`) + '.Shop::addSqlAssociation('product', 'p').' 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 OUTER JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND `default_on` = 1) + LEFT OUTER JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`) + '.Shop::addSqlAssociation('product_attribute', 'pa').' LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`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.`active` = 1 + WHERE product_shop.`active` = 1 + AND product_attribute_shop.`default_on` = 1 '.($id_customer ? ' AND fp.id_customer = '.(int)$id_customer : '').' '.Shop::addSqlRestriction(false, 'fp') ); diff --git a/modules/gsitemap/gsitemap.php b/modules/gsitemap/gsitemap.php index 400f1b2e2..de817e4d2 100644 --- a/modules/gsitemap/gsitemap.php +++ b/modules/gsitemap/gsitemap.php @@ -137,14 +137,14 @@ XML; /** * Generate a sitemap for a shop * - * @param int $shopID + * @param int $id_shop * @param string $filename * @return bool */ - private function generateSitemap($shopID, $filename = '', $replaceUrl = array()) + private function generateSitemap($id_shop, $filename = '', $replace_url = array()) { $langs = Language::getLanguages(); - $shop = new Shop($shopID); + $shop = new Shop($id_shop); if (!$shop->id) return false; @@ -164,25 +164,26 @@ XML; $this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__, '1.00', 'daily', date('Y-m-d')); /* Product Generator */ - $sql = 'SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') date_upd, pl.id_lang, cl.`link_rewrite` category, ean13, i.id_image, il.legend legend_image, ( + $sql = 'SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(ps.date_upd,ps.date_upd,ps.date_add), \'%Y-%m-%d\') date_upd, pl.id_lang, cl.`link_rewrite` category, ean13, i.id_image, il.legend legend_image, ( SELECT MIN(level_depth) FROM '._DB_PREFIX_.'product p2 + '.Shop::addSqlAssociation('product', 'p2').' LEFT JOIN '._DB_PREFIX_.'category_product cp2 ON p2.id_product = cp2.id_product LEFT JOIN '._DB_PREFIX_.'category c2 ON cp2.id_category = c2.id_category - WHERE p2.id_product = p.id_product AND p2.`active` = 1 AND c2.`active` = 1) AS level_depth + WHERE p2.id_product = p.id_product AND product_shop.`active` = 1 AND c2.`active` = 1) AS level_depth FROM '._DB_PREFIX_.'product p - LEFT JOIN '._DB_PREFIX_.'product_shop ps ON ps.id_product = p.id_product - LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_shop ='.$shopID.') - LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (ps.id_category_default = cl.id_category AND pl.id_lang = cl.id_lang AND cl.id_shop = '.$shopID.') + LEFT JOIN '._DB_PREFIX_.'product_shop ps ON (ps.id_product = p.id_product AND ps.id_shop = '.(int)$id_shop.') + LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product) + LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (ps.id_category_default = cl.id_category AND pl.id_lang = cl.id_lang AND cl.id_shop = '.(int)$id_shop.') LEFT JOIN '._DB_PREFIX_.'image i ON p.id_product = i.id_product LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image) LEFT JOIN '._DB_PREFIX_.'lang l ON (pl.id_lang = l.id_lang) WHERE l.`active` = 1 - AND p.`active` = 1 - AND ps.id_shop = '.$shopID.' + AND ps.`active` = 1 + AND ps.id_shop = '.(int)$id_shop.' '.(Configuration::get('GSITEMAP_ALL_PRODUCTS') ? '' : 'HAVING level_depth IS NOT NULL').' ORDER BY pl.id_product, pl.id_lang ASC'; - + $resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql); // array used to know which product/image was already added (blacklist) @@ -301,14 +302,14 @@ XML; foreach($pages as $page => $ssl) $this->_addSitemapNode($xml, $this->context->link->getPageLink($page, $ssl), '0.5', 'monthly'); - $xmlString = $xml->asXML(); + $xml_string = $xml->asXML(); // Replace URL in XML strings by real shops URL - if ($replaceUrl) - $xmlString = str_replace(array(Tools::getShopDomain(true).'/', Tools::getShopDomainSsl(true).'/'), $replaceUrl, $xmlString); + if ($replace_url) + $xml_string = str_replace(array(Tools::getShopDomain(true).'/', Tools::getShopDomainSsl(true).'/'), $replace_url, $xml_string); $fp = fopen($filename, 'w'); - fwrite($fp, $xmlString); + fwrite($fp, $xml_string); fclose($fp); return file_exists($filename); diff --git a/modules/mailalerts/MailAlert.php b/modules/mailalerts/MailAlert.php index f5cbc5843..5eff978d6 100644 --- a/modules/mailalerts/MailAlert.php +++ b/modules/mailalerts/MailAlert.php @@ -213,8 +213,9 @@ class MailAlert extends ObjectModel SELECT ma.`id_product`, p.`quantity` AS product_quantity, pl.`name`, ma.`id_product_attribute` FROM `'._DB_PREFIX_.self::$definition['table'].'` ma JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = ma.`id_product` + '.Shop::addSqlAssociation('product', 'p').' JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = ma.`id_product` - WHERE p.`active` = 1 + WHERE product_shop.`active` = 1 AND (ma.`id_customer` = '.(int)$customer->id.' OR ma.`customer_email` = \''.pSQL($customer->email).'\') AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestriction(false, 'ma'); @@ -235,6 +236,7 @@ class MailAlert extends ObjectModel LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pac.`id_product_attribute` = pa.`id_product_attribute`) + '.Shop::addSqlAssociation('product_attribute', 'pa').' WHERE pac.`id_product_attribute` = '.(int)$id_product_attribute; return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); diff --git a/modules/pagesnotfound/pagesnotfound.php b/modules/pagesnotfound/pagesnotfound.php index 8cee0418a..640b2787c 100644 --- a/modules/pagesnotfound/pagesnotfound.php +++ b/modules/pagesnotfound/pagesnotfound.php @@ -54,7 +54,7 @@ class Pagesnotfound extends Module CREATE TABLE `'._DB_PREFIX_.'pagenotfound` ( id_pagenotfound INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, id_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\', - id_group_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\', + id_shop_group INTEGER UNSIGNED NOT NULL DEFAULT \'1\', request_uri VARCHAR(256) NOT NULL, http_referer VARCHAR(256) NOT NULL, date_add DATETIME NOT NULL, @@ -173,8 +173,8 @@ class Pagesnotfound extends Module $http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; if (empty($http_referer) || Validate::isAbsoluteUrl($http_referer)) Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'pagenotfound` (`request_uri`, `http_referer`, `date_add`, `id_shop`, `id_group_shop`) - VALUES (\''.pSQL($request_uri).'\', \''.pSQL($http_referer).'\', NOW(), '.(int)$this->context->shop->id.', '.(int)$this->context->shop->id_group_shop.') + INSERT INTO `'._DB_PREFIX_.'pagenotfound` (`request_uri`, `http_referer`, `date_add`, `id_shop`, `id_shop_group`) + VALUES (\''.pSQL($request_uri).'\', \''.pSQL($http_referer).'\', NOW(), '.(int)$this->context->shop->id.', '.(int)$this->context->shop->id_shop_group.') '); } } diff --git a/modules/sekeywords/sekeywords.php b/modules/sekeywords/sekeywords.php index b32f5fa5d..a82d9b0cc 100644 --- a/modules/sekeywords/sekeywords.php +++ b/modules/sekeywords/sekeywords.php @@ -68,7 +68,7 @@ class SEKeywords extends ModuleGraph CREATE TABLE `'._DB_PREFIX_.'sekeyword` ( id_sekeyword INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, id_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\', - id_group_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\', + id_shop_group INTEGER UNSIGNED NOT NULL DEFAULT \'1\', keyword VARCHAR(256) NOT NULL, date_add DATETIME NOT NULL, PRIMARY KEY(id_sekeyword) @@ -88,8 +88,8 @@ class SEKeywords extends ModuleGraph return; if ($keywords = $this->getKeywords($_SERVER['HTTP_REFERER'])) - Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'sekeyword` (`keyword`, `date_add`, `id_shop`, `id_group_shop`) - VALUES (\''.pSQL(Tools::strtolower(trim($keywords))).'\', NOW(), '.(int)$this->context->shop->id.', '.(int)$this->context->shop->id_group_shop.')'); + Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'sekeyword` (`keyword`, `date_add`, `id_shop`, `id_shop_group`) + VALUES (\''.pSQL(Tools::strtolower(trim($keywords))).'\', NOW(), '.(int)$this->context->shop->id.', '.(int)$this->context->shop->id_shop_group.')'); } public function hookAdminStatsModules() diff --git a/modules/shopimporter/shopimporter.php b/modules/shopimporter/shopimporter.php index dea6717f9..88a51cab9 100644 --- a/modules/shopimporter/shopimporter.php +++ b/modules/shopimporter/shopimporter.php @@ -1244,6 +1244,7 @@ class shopimporter extends ImportModule break; case 'combination' : Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute'); + Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute_shop'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute_combination'); break; case 'category' : @@ -1257,6 +1258,7 @@ class shopimporter extends ImportModule break; case 'product' : Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product'); + Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_shop'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'feature_product'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_lang'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'category_product'); @@ -1264,6 +1266,7 @@ class shopimporter extends ImportModule Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'image'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'image_lang'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute'); + Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute_shop'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_attribute_combination'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'specific_price'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'specific_price_priority'); diff --git a/modules/statsbestproducts/statsbestproducts.php b/modules/statsbestproducts/statsbestproducts.php index aae379012..44a18caa7 100644 --- a/modules/statsbestproducts/statsbestproducts.php +++ b/modules/statsbestproducts/statsbestproducts.php @@ -153,7 +153,7 @@ class StatsBestProducts extends ModuleGrid ROUND(AVG(od.product_price / o.conversion_rate), 2) as avgPriceSold, IFNULL(stock.quantity, 0) as quantity, IFNULL(SUM(od.product_quantity), 0) AS totalQuantitySold, - ROUND(IFNULL(IFNULL(SUM(od.product_quantity), 0) / (1 + LEAST(TO_DAYS('.$arrayDateBetween[1].'), TO_DAYS(NOW())) - GREATEST(TO_DAYS('.$arrayDateBetween[0].'), TO_DAYS(p.date_add))), 0), 2) as averageQuantitySold, + ROUND(IFNULL(IFNULL(SUM(od.product_quantity), 0) / (1 + LEAST(TO_DAYS('.$arrayDateBetween[1].'), TO_DAYS(NOW())) - GREATEST(TO_DAYS('.$arrayDateBetween[0].'), TO_DAYS(product_shop.date_add))), 0), 2) as averageQuantitySold, ROUND(IFNULL(SUM((od.product_price * od.product_quantity) / o.conversion_rate), 0), 2) AS totalPriceSold, ( SELECT IFNULL(SUM(pv.counter), 0) @@ -170,7 +170,7 @@ class StatsBestProducts extends ModuleGrid LEFT JOIN '._DB_PREFIX_.'order_detail od ON od.product_id = p.id_product LEFT JOIN '._DB_PREFIX_.'orders o ON od.id_order = o.id_order '.Product::sqlStock('p', 0).' - WHERE p.active = 1 + WHERE product_shop.active = 1 AND o.valid = 1 AND o.invoice_date BETWEEN '.$dateBetween.' GROUP BY od.product_id'; diff --git a/modules/statscatalog/statscatalog.php b/modules/statscatalog/statscatalog.php index b0e8027e3..9a63e147d 100644 --- a/modules/statscatalog/statscatalog.php +++ b/modules/statscatalog/statscatalog.php @@ -54,11 +54,12 @@ class StatsCatalog extends Module public function getQuery1() { - $sql = 'SELECT COUNT(DISTINCT p.`id_product`) AS total, SUM(p.`price`) / COUNT(`price`) AS average_price, COUNT(DISTINCT i.`id_image`) AS images + $sql = 'SELECT COUNT(DISTINCT p.`id_product`) AS total, SUM(product_shop.`price`) / COUNT(`product_shop.price`) AS average_price, COUNT(DISTINCT i.`id_image`) AS images FROM `'._DB_PREFIX_.'product` p + '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'image` i ON i.`id_product` = p.`id_product` '.$this->_join.' - WHERE p.`active` = 1 + WHERE product_shop.`active` = 1 '.$this->_where; return DB::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); } @@ -66,12 +67,13 @@ class StatsCatalog extends Module public function getTotalPageViewed() { $sql = 'SELECT SUM(pv.`counter`) AS viewed - FROM `'._DB_PREFIX_.'product` p + FROM `'._DB_PREFIX_.'product` p + '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'page` pa ON p.`id_product` = pa.`id_object` LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON (pt.`id_page_type` = pa.`id_page_type` AND pt.`name` = \'product.php\') LEFT JOIN `'._DB_PREFIX_.'page_viewed` pv ON pv.`id_page` = pa.`id_page` '.$this->_join.' - WHERE p.`active` = 1 + WHERE product_shop.`active` = 1 '.$this->_where; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return isset($result['viewed']) ? $result['viewed'] : 0; @@ -84,9 +86,10 @@ class StatsCatalog extends Module LEFT JOIN `'._DB_PREFIX_.'page` pa ON pv.`id_page` = pa.`id_page` LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = pa.`id_page_type` LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = pa.`id_object` + '.Shop::addSqlAssociation('product', 'p').' '.$this->_join.' WHERE pt.`name` = \'product.php\' - AND p.`active` = 1 + AND product_shop.`active` = 1 '.$this->_where; return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); } @@ -110,10 +113,11 @@ class StatsCatalog extends Module FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.`id_order` = od.`id_order` LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = od.`product_id` + '.Shop::addSqlAssociation('product', 'p').' '.$this->_join.' WHERE o.valid = 1 '.$this->_where.' - AND p.`active` = 1 + AND product_shop.`active` = 1 GROUP BY p.`id_product`'; $precalc = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); @@ -123,10 +127,11 @@ class StatsCatalog extends Module $sql = 'SELECT p.id_product, pl.name, pl.link_rewrite FROM `'._DB_PREFIX_.'product` p + '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').') '.$this->_join.' - WHERE p.`active` = 1 + WHERE product_shop.`active` = 1 '.(count($precalc2) ? 'AND p.`id_product` NOT IN ('.implode(',', $precalc2).')' : '').' '.$this->_where; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); diff --git a/modules/statscheckup/statscheckup.php b/modules/statscheckup/statscheckup.php index 18accded0..b846d5fb3 100644 --- a/modules/statscheckup/statscheckup.php +++ b/modules/statscheckup/statscheckup.php @@ -123,7 +123,7 @@ class StatsCheckUp extends Module $orderBy = 'nbSales DESC'; // Get products stats - $sql = 'SELECT p.id_product, p.active, pl.name, ( + $sql = 'SELECT p.id_product, product_shop.active, pl.name, ( SELECT COUNT(*) FROM '._DB_PREFIX_.'image i '.Shop::addSqlAssociation('image', 'i').' @@ -138,10 +138,10 @@ class StatsCheckUp extends Module ) as nbSales, IFNULL(stock.quantity, 0) as stock FROM '._DB_PREFIX_.'product p + '.Shop::addSqlAssociation('product', 'p').' '.Product::sqlStock('p', 0).' LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('pl').') - '.Shop::addSqlAssociation('product', 'p').' ORDER BY '.$orderBy; $result = $db->executeS($sql); diff --git a/modules/statsforecast/statsforecast.php b/modules/statsforecast/statsforecast.php index 5eabeb5bf..fb814d6ab 100644 --- a/modules/statsforecast/statsforecast.php +++ b/modules/statsforecast/statsforecast.php @@ -500,13 +500,13 @@ class StatsForecast extends Module LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = od.product_id '.Shop::addSqlAssociation('product', 'p').' - LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (asso_shop_product.id_category_default = cl.id_category AND cl.id_lang = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('cl').') + LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (product_shop.id_category_default = cl.id_category AND cl.id_lang = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('cl').') '.$join.' WHERE o.valid = 1 AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().' '.$where.' '.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').' - GROUP BY asso_shop_product.id_category_default'; + GROUP BY product_shop.id_category_default'; $ca['cat'] = Db::getInstance()->executeS($sql); uasort($ca['cat'], 'statsforecast_sort'); diff --git a/modules/statssearch/statssearch.php b/modules/statssearch/statssearch.php index f92d663fa..2f7b3920f 100644 --- a/modules/statssearch/statssearch.php +++ b/modules/statssearch/statssearch.php @@ -66,7 +66,7 @@ class StatsSearch extends ModuleGraph CREATE TABLE `'._DB_PREFIX_.'statssearch` ( id_statssearch INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, id_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\', - id_group_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\', + id_shop_group INTEGER UNSIGNED NOT NULL DEFAULT \'1\', keywords VARCHAR(255) NOT NULL, results INT(6) NOT NULL DEFAULT 0, date_add DATETIME NOT NULL, @@ -86,8 +86,8 @@ class StatsSearch extends ModuleGraph */ public function hookSearch($params) { - $sql = 'INSERT INTO `'._DB_PREFIX_.'statssearch` (`id_shop`, `id_group_shop`, `keywords`, `results`, `date_add`) - VALUES ('.(int)$this->context->shop->id.', '.(int)$this->context->shop->id_group_shop.', \''.pSQL($params['expr']).'\', '.(int)$params['total'].', NOW())'; + $sql = 'INSERT INTO `'._DB_PREFIX_.'statssearch` (`id_shop`, `id_shop_group`, `keywords`, `results`, `date_add`) + VALUES ('.(int)$this->context->shop->id.', '.(int)$this->context->shop->id_shop_group.', \''.pSQL($params['expr']).'\', '.(int)$params['total'].', NOW())'; Db::getInstance()->execute($sql); } diff --git a/modules/statsstock/statsstock.php b/modules/statsstock/statsstock.php index c802370b3..266132620 100644 --- a/modules/statsstock/statsstock.php +++ b/modules/statsstock/statsstock.php @@ -62,10 +62,12 @@ class StatsStock extends Module $sql = 'SELECT p.id_product, p.reference, pl.name, IFNULL(( - SELECT AVG(pa.wholesale_price) - FROM '._DB_PREFIX_.'product_attribute pa WHERE p.id_product = pa.id_product - AND wholesale_price != 0 - ), p.wholesale_price) as wholesale_price, + SELECT AVG(product_attribute_shop.wholesale_price) + FROM '._DB_PREFIX_.'product_attribute pa + '.Shop::addSqlAssociation('product_attribute', 'pa').' + WHERE p.id_product = pa.id_product + AND product_attribute_shop.wholesale_price != 0 + ), product_shop.wholesale_price) as wholesale_price, IFNULL(stock.quantity, 0) as quantity FROM '._DB_PREFIX_.'product p '.Shop::addSqlAssociation('product', 'p').' diff --git a/override/classes/GroupShop.php b/override/classes/GroupShop.php deleted file mode 100644 index f85486195..000000000 --- a/override/classes/GroupShop.php +++ /dev/null @@ -1,7 +0,0 @@ -