I am trying to disable the out of stock products that appear on the price-drop page. I do not see the point of putting on sale products that are out of stock. We sometimes forget to remove the discount and customers complain about it.
$sql ='
SELECT
p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`,
MAX(product_attribute_shop.id_product_attribute) id_product_attribute,
pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`,
pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
DATEDIFF(
p.`date_add`,
DATE_SUB(
NOW(),
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT'))?Configuration::get('PS_NB_DAYS_NEW_PRODUCT'):20).' DAY
)
) > 0 AS new
FROM `'._DB_PREFIX_.'product` p
'.Shop::addSqlAssociation('product','p').'
LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON (pa.id_product = p.id_product)
'.Shop::addSqlAssociation('product_attribute','pa',false,'product_attribute_shop.default_on=1').'
'.Product::sqlStock('p',0,false, $context->shop).'
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`)'.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`)
WHERE product_shop.`active` = 1
AND product_shop.`show_price` = 1
I added AND stock.`quantity` > 0
'.($front ? ' AND p.`visibility` IN ("both","catalog")' : '').''.((!$beginning && !$ending) ? ' AND p.`id_product` IN ('.((is_array($tab_id_product) && count($tab_id_product)) ? implode(',', $tab_id_product) : 0).')' : '').''.$sql_groups.'
GROUP BY product_shop.id_product
ORDER BY '.(isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').pSQL($order_by).''.pSQL($order_way).'
LIMIT '.(int)($page_number * $nb_products).','.(int)$nb_products;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!$result)
return false;
However, it dit not work at all and I am not sure why. I did the usual: clear caches, etc. No dice and I am not sure why.
Anybody else can point me in the right direction or tell me what I am doing wrong?
Question
movieseals
Hi everyone,
I am trying to disable the out of stock products that appear on the price-drop page. I do not see the point of putting on sale products that are out of stock. We sometimes forget to remove the discount and customers complain about it.
So, here is what I tried to do:
I looked into the file classes/Product.php:
I found the function:
In there, in the SQL code:
However, it dit not work at all and I am not sure why. I did the usual: clear caches, etc. No dice and I am not sure why.
Anybody else can point me in the right direction or tell me what I am doing wrong?
7 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now