Created
September 12, 2020 07:24
-
-
Save unlocomqx/1fad8d741a29f6248bc6a5f1b23f347d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// CategoryCore::getProducts | |
// Changer la requête à | |
$sql = 'SELECT product_shop.cache_default_attribute, p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity' . (Combination::isFeatureActive() ? ', IFNULL(product_attribute_shop.id_product_attribute, 0) AS id_product_attribute, | |
product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity' : '') . ', pl.`description`, pl.`description_short`, pl.`available_now`, | |
pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, image_shop.`id_image` id_image, | |
il.`legend` as legend, m.`name` AS manufacturer_name, cl.`name` AS category_default, | |
DATEDIFF(product_shop.`date_add`, DATE_SUB("' . date('Y-m-d') . ' 00:00:00", | |
INTERVAL ' . (int) $nbDaysNewProduct . ' DAY)) > 0 AS new, product_shop.price AS orderprice | |
FROM `' . _DB_PREFIX_ . 'category_product` cp | |
LEFT JOIN `' . _DB_PREFIX_ . 'product` p | |
ON p.`id_product` = cp.`id_product` | |
' . Shop::addSqlAssociation('product', 'p') . | |
(Combination::isFeatureActive() ? ' LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_shop` product_attribute_shop | |
ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`default_on` = 1 AND product_attribute_shop.id_shop=' . (int) $context->shop->id . ')' : '') . ' | |
' . Product::sqlStock('p', 0) . ' | |
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl | |
ON (product_shop.`id_category_default` = cl.`id_category` | |
AND cl.`id_lang` = ' . (int) $idLang . Shop::addSqlRestrictionOnLang('cl') . ') | |
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl | |
ON (p.`id_product` = pl.`id_product` | |
AND pl.`id_lang` = ' . (int) $idLang . Shop::addSqlRestrictionOnLang('pl') . ') | |
LEFT JOIN `' . _DB_PREFIX_ . 'image_shop` image_shop | |
ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $context->shop->id . ') | |
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il | |
ON (image_shop.`id_image` = il.`id_image` | |
AND il.`id_lang` = ' . (int) $idLang . ') | |
LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m | |
ON m.`id_manufacturer` = p.`id_manufacturer` | |
WHERE product_shop.`id_shop` = ' . (int) $context->shop->id . ' | |
AND cp.`id_category` = ' . (int) $this->id | |
. ($active ? ' AND product_shop.`active` = 1' : '') | |
. ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') | |
. ($idSupplier ? ' AND p.id_supplier = ' . (int) $idSupplier : ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ProductAssembler::addMissingProductFields | |
// Changer la variable $sql à | |
$sql = "SELECT | |
p.*, | |
pl.*, | |
ps.`cache_default_attribute` as cache_default_attribute, | |
sa.out_of_stock, | |
IFNULL(sa.quantity, 0) as quantity, | |
(DATEDIFF( | |
p.`date_add`, | |
DATE_SUB( | |
'$now', | |
INTERVAL $nbDaysNewProduct DAY | |
) | |
) > 0) as new | |
FROM {$prefix}product p | |
LEFT JOIN {$prefix}product_lang pl | |
ON pl.id_product = p.id_product | |
AND pl.id_shop = $idShop | |
AND pl.id_lang = $idLang | |
LEFT JOIN {$prefix}stock_available sa | |
ON sa.id_product = p.id_product | |
AND sa.id_shop = $idShop | |
LEFT JOIN {$prefix}product_shop ps | |
ON ps.id_product = p.id_product | |
AND ps.id_shop = $idShop | |
WHERE p.id_product = $idProduct"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment