thenortherncold Posted April 11, 2010 Share Posted April 11, 2010 Does anyone know how I can have PrestaShop automatically disable an item when it becomes out of stock?While it does not permit anyone from purchasing out of stock items I would much prefer to see them disabled so as to not clutter up the page.TIA Link to comment Share on other sites More sharing options...
blk1 Posted April 23, 2010 Share Posted April 23, 2010 I have clicked No to Display unavailable product attributes on product page: in the Preferences > Products section and am hoping that this is the right one for disabling items out of stock, I haven't had any yet so can't say if it works or not. Link to comment Share on other sites More sharing options...
nuttis Posted April 30, 2010 Share Posted April 30, 2010 blk1: that will only disable attributes that are out of stock. Link to comment Share on other sites More sharing options...
rocky Posted May 1, 2010 Share Posted May 1, 2010 To automatically disable the products once they go out of stock is not an easy thing to do. It would be easier to just leave the products enabled and simply hide them from the product lists. To do this, edit changes lines 418-419 of classes/Category.php (in Prestashop v1.2.5) from: WHERE cp.`id_category` = '.intval($this->id).($active ? ' AND p.`active` = 1' : '').' '.($id_supplier ? 'AND p.id_supplier = '.$id_supplier : ''); to: WHERE p.`quantity` > 0 AND cp.`id_category` = '.intval($this->id).($active ? ' AND p.`active` = 1' : '').' '.($id_supplier ? 'AND p.id_supplier = '.$id_supplier : ''); This will hide out-of-stock products when you click on a category, but they'll still appear in search results and on some other pages. To remove them from the search results, change line 148 of classes/Search.php from: $whereArray[] = ' p.id_product '.($word[0] == '-' ? 'NOT' : '').' IN ( to: $whereArray[] = ' p.`quantity` > 0 AND p.id_product '.($word[0] == '-' ? 'NOT' : '').' IN ( To remove the out-of-stock products from the best sellers list, change lines 72 and 114 of classes/ProductSales.php (in Prestashop v1.2.5) to:from: WHERE p.`active` = 1 to: WHERE p.`active` = 1 AND p.`quantity` > 0 To remove the out-of-stock products from the specials list, change line 1048 of classes/Product.php (in Prestashop v1.2.5) from: AND p.`active` = 1 to: AND p.`active` = 1 AND p.`quantity` > 0 I haven't tested this code, but it should work. There may be other places that also need to be changed. Link to comment Share on other sites More sharing options...
Jubri Posted May 3, 2010 Share Posted May 3, 2010 What about, a button with next command?UPDATE ps_productSET active = 0WHERE quantity = 0EDIT: Oh, sorry, this is not automatic... Regards. Link to comment Share on other sites More sharing options...
FunnyBunnyHelena Posted August 25, 2010 Share Posted August 25, 2010 Is this still an issue in the latest version?On Zen-Cart which I used before, I could set so that if someone buy the product will be automatically disabled and not showing in the shop. This is good when selling unique items, which I do. Because if it is sold then it is gone and not really will be more added later.Hmm.. maybe meanwhile I will change the text out of stock to sold simply..But I am hoping for this auto-disable to be added to the new version of Presta because it is bothersome to manually disable items when it is sold. Link to comment Share on other sites More sharing options...
steve_c Posted November 28, 2010 Share Posted November 28, 2010 Hi I get an error when I try to edit the category.php class with the fixes mentioned above. Has anyone got this fix working for 1.3? My shop is completely unusable unless I can hide products which are sold out Link to comment Share on other sites More sharing options...
steve_c Posted November 28, 2010 Share Posted November 28, 2010 Please ignore the above - I got it working. Link to comment Share on other sites More sharing options...
Danman Posted November 28, 2010 Share Posted November 28, 2010 If you solved it steve_c, please share. Thats what a community forum is all about We are many that need this function working. So very strange that its not included in prestashop. Link to comment Share on other sites More sharing options...
steve_c Posted December 1, 2010 Share Posted December 1, 2010 Hi - the text is slightly different in 1.3.2 so I just searched for any SQL WHERE terms relating to the product and added the qty > 0.Unfortunately this above code does not seem to work with the "Manufacurers" block. It still shows out of stock items for manufacturers. I'm very much new to PrestaShop so would anyone know which file I would need to work on?Thanks in advance!Stephen. Link to comment Share on other sites More sharing options...
leveau Posted December 7, 2010 Share Posted December 7, 2010 hi, has anyone managed to make this work for version 1.3.2.3?i would be very interested to see this work- selling antiques, so one and unique item every time.thank youlev. Link to comment Share on other sites More sharing options...
steve_c Posted December 7, 2010 Share Posted December 7, 2010 No - it's not in there. It also doesn't look as if it's in 1.4.There is a fix somewhere in these forums but it doesn't work for "New products" or on the "Manufacturers" page. It's a real shame Link to comment Share on other sites More sharing options...
Danman Posted December 7, 2010 Share Posted December 7, 2010 Thats right steve_c, it´s not included in 1.4. I have looked at 5-6 other e-commerce software and Prestashop is the ONLY one that dont have this function! It may seem like an smal thing, but to hide out-of-stock products is essential in many business models.Here are feature request for this: (But I doubt Prestashop-team ever read them...)http://www.prestashop.com/bug_tracker/view/not_display_a_product_out_of_stock/ Link to comment Share on other sites More sharing options...
steve_c Posted December 7, 2010 Share Posted December 7, 2010 I've added a reply. I really really hope they can put this in the next version. On a side note - did you go with another solution for now or are you hacking prestashop?Stephen Link to comment Share on other sites More sharing options...
Danman Posted December 9, 2010 Share Posted December 9, 2010 I have used CS-Cart for a couple of years. It´s a great system but it lacks many country specific modules/integration that would make my work more easy. The module-system is Prestashops strength.I dont like to hack to much, it make it so harder to upgrade to a newer version + i´m not a coder... Link to comment Share on other sites More sharing options...
steve_c Posted December 9, 2010 Share Posted December 9, 2010 It would be fantastic if someone would make a module which checked qty of an item when you checked out. If qty == 0 then prod.enabled = false Link to comment Share on other sites More sharing options...
Danman Posted December 9, 2010 Share Posted December 9, 2010 The problem steve_c is that you have to make changes to the core code and a module can´t do that.Maybe the new feature "Overriding PrestaShop Core" in 1.4 will fix it, I dont know.. Link to comment Share on other sites More sharing options...
Daniel Ciornei Posted December 16, 2010 Share Posted December 16, 2010 how to remove out of stock only in new products?UPDATE: figured that out, just modified classes/product.php with an extra while in newProducts function. Link to comment Share on other sites More sharing options...
steve_c Posted December 20, 2010 Share Posted December 20, 2010 Hi Daniel can you tell me exactly how you did this?On a side note to any developers reading - I've received in total about 10 complaints within 2 weeks from customers saying that the shop is very confusing because half of the products are no longer in stock (in New products, manufacturers link etc). I really think this is an issue that needs looking at if possible... Link to comment Share on other sites More sharing options...
Daniel Ciornei Posted December 20, 2010 Share Posted December 20, 2010 just edited classes/product.php replace LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE p.`active` = 1 AND 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) with LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE p.`active` = 1 AND p.`quantity` > 0 AND 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) in the getNewProducts function. Link to comment Share on other sites More sharing options...
aura Posted May 5, 2011 Share Posted May 5, 2011 Thats right steve_c, it´s not included in 1.4. I have looked at 5-6 other e-commerce software and Prestashop is the ONLY one that dont have this function! It may seem like an smal thing, but to hide out-of-stock products is essential in many business models.Here are feature request for this: (But I doubt Prestashop-team ever read them...)http://www.prestashop.com/bug_tracker/view/not_display_a_product_out_of_stock/ Hi Danman,I mistakenly assumed Prestashop had this function when I started developing a new clients site, so now I'll have to resort to hacking the code, which I'm not confident about doing..I've added a comment to your feature request and hoping it may help jog the Prestashop team into action Link to comment Share on other sites More sharing options...
mr10 Posted July 8, 2011 Share Posted July 8, 2011 What about, a button with next command?UPDATE ps_productSET active = 0WHERE quantity = 0EDIT: Oh, sorry, this is not automatic... Regards. i like this approach...if you add this line at the place where the stock gets changed, this would work automatically!is that classes/StockMvt.php ? or somewhere else? Link to comment Share on other sites More sharing options...
mr10 Posted July 9, 2011 Share Posted July 9, 2011 thank you angora!this works perfectly, just by putting 1 file in 1 folder...i tested it, and it works Link to comment Share on other sites More sharing options...
xiawa Posted August 11, 2011 Share Posted August 11, 2011 just edited classes/product.php <br/>replace <br/> LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)<br/> WHERE p.`active` = 1<br/> AND 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) <br/><br/>with<br/> LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)<br/> WHERE p.`active` = 1<br/> AND p.`quantity` > 0<br/> AND 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) <br/><br/>in the getNewProducts function. works perfectly, thanks. Link to comment Share on other sites More sharing options...
3antz Posted September 10, 2011 Share Posted September 10, 2011 hi there, I'm facing similar challenges to hide Out of Stock items. I tried the workaround suggested to include "AND p.`quantity` > 0' into products.php but it doesn't seem to be working. I noticed that the code is different in PS 1.4. Can anyone please help me out? LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE p.`active` = 1 AND p.`quantity` > 0 AND DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get( Link to comment Share on other sites More sharing options...
3antz Posted September 11, 2011 Share Posted September 11, 2011 hi does anyone have a solution to this? Thanks Link to comment Share on other sites More sharing options...
plauengco Posted October 4, 2011 Share Posted October 4, 2011 I have hidden all my out of stock products in 1.4.4 by including the following condition in product-list.tpl: {if ($product.allow_oosp || $product.quantity > 0)} However, if I wanted to show some out of stock products while hiding others, you can include instead: {if isset($product.available_for_order) && $product.available_for_order} This is more manual, but for each product in the backend, you can just uncheck the box on the right side for "available for order". Both won't disable the product pages but hides them in category list to prevent 404 errors during search engine crawl. Insert code after {foreach from=$products item=product name=products} 1 Link to comment Share on other sites More sharing options...
plauengco Posted October 5, 2011 Share Posted October 5, 2011 Actually the code above hides them from being seen, but they actually still there just not taking space, eg. (10 products shown, but only see 8 because 2 are out of stock.) @rocky thanks to the modification you proposed! I managed to get it working for categories on Prestashop 1.4.4 by changing WHERE cp.`id_category` = '.intval($this->id).($active ? ' AND p.`active` = 1' : '').' '.($id_supplier ? 'AND p.id_supplier = '.$id_supplier : ''); to WHERE cp.`id_category` = '.(int)($this->id).($active ? ' AND p.`active` = 1' : '').' '.($id_supplier ? 'AND p.id_supplier = '.(int)($id_supplier) : '')); However, it seems that the Search.php code is a lot different in 1.4.4 and I couldn't find anywhere anything that resembles the fix you suggested. Can you share your thoughts on how to hide out of stock products in 1.4? Thanks, rocky! Link to comment Share on other sites More sharing options...
mr10 Posted November 2, 2011 Share Posted November 2, 2011 as posts by 'angora' disappeared and with it the solution i used, i put the solution here again: make a file called "ProductSale.php" in /override/classes/ with following code: <?php class ProductSale extends ProductSaleCore { // called for each product contained within an order, when an order's status is marked 'logable' (aka verified/paid) static public function addProductSale($product_id, $qty = 1) { $goober = Db::getInstance()->Execute(' INSERT INTO '._DB_PREFIX_.'product_sale (`id_product`, `quantity`, `sale_nbr`, `date_upd`) VALUES ('.(int)($product_id).', '.(float)($qty).', 1, NOW()) ON DUPLICATE KEY UPDATE `quantity` = `quantity` + '.(float)($qty).', `sale_nbr` = `sale_nbr` + 1, `date_upd` = NOW()' ); // check remaining product quantity subsequent to the sale transaction and, if sold out, set product.active=0 (aka disabled/draft, does not display in catalog) $smurf = Db::getInstance()->getValue('SELECT `quantity` from `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$product_id); if ($smurf <= 0 ) { Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product` SET `active` ='. (int)0 .' WHERE `id_product` = '.(int)$product_id); } return $goober; } } ?> that worked for me on 1.4 1 Link to comment Share on other sites More sharing options...
tukker Posted November 3, 2011 Share Posted November 3, 2011 mr10, thank you for the posting. I only made a file "productsale.php" and put it in /override/classes/ that's all ?? I test it with an order, product quantity = 0 but the product is still active. So for me it is not working. I use 1.4.5.1. Have somebody an idea, how to get it work in 1.4.5.1 Link to comment Share on other sites More sharing options...
mr10 Posted November 3, 2011 Share Posted November 3, 2011 don't know if it matters, but did you use capitals? ProductSale.php (not productsale.php) i have tried it back then and it worked on 1.4.1, but do not use it anymore, because the client did not want this feature anymore, so i do not know if it is still the complete solution, sorry... Link to comment Share on other sites More sharing options...
tukker Posted November 3, 2011 Share Posted November 3, 2011 Yes I use the capitals Can somebody test this in 1.4.5.1 It is frustrating that if the last product is ordered that the product is active on the site. I hope someone has the solution. Link to comment Share on other sites More sharing options...
tukker Posted November 5, 2011 Share Posted November 5, 2011 Is there something else what I have to do ? Only put the file in /override/classes Please is there anybody who can help me. I need it for my webshop. Link to comment Share on other sites More sharing options...
philee Posted December 6, 2011 Share Posted December 6, 2011 I'm having the same issue. I am using Store Manager to update the product quantity to "0" and it showed up the "Notify me when available" However, I am still able to add a product to stock and check-out. Also, it still shows it's available. I checked the back-office product page, and it shows the combination attributes still "1" I believe this is what's causing the product still be labeled as available yet unavailable. Anyway where if the product quantity is set to zero that the product will be unavailable to add to cart? Link to comment Share on other sites More sharing options...
Danman Posted December 6, 2011 Share Posted December 6, 2011 Please everyone! Vote on the Forge for the feature "Disable product when out of stock" Maybe together we can get the message to the Prestashop-team to include it in the next version. It would make things much more easier for many of us using prestashop. http://forge.prestas...owse/PSCFI-1630 1 Link to comment Share on other sites More sharing options...
Rose24 Posted December 8, 2011 Share Posted December 8, 2011 Please everyone! Vote on the Forge for the feature "Disable product when out of stock" Maybe together we can get the message to the Prestashop-team to include it in the next version. It would make things much more easier for many of us using prestashop. http://forge.prestas...owse/PSCFI-1630 agree..so we can have much easier to use pretashop. 1 Link to comment Share on other sites More sharing options...
Danman Posted February 3, 2012 Share Posted February 3, 2012 Maybe some chance to get this in Prestashop 1.5. If you need the feature "Disable product when out of stock" it could be a good idee for you to leave a comment in this thread: http://www.prestashop.com/forums/topic/153762-15-request-automatically-disablehide-product-when-out-of-stock/ Together we could make this happen! Link to comment Share on other sites More sharing options...
matoh Posted February 10, 2012 Share Posted February 10, 2012 as posts by 'angora' disappeared and with it the solution i used, i put the solution here again: make a file called "ProductSale.php" in /override/classes/ with following code: <?php class ProductSale extends ProductSaleCore { // called for each product contained within an order, when an order's status is marked 'logable' (aka verified/paid) static public function addProductSale($product_id, $qty = 1) { $goober = Db::getInstance()->Execute(' INSERT INTO '._DB_PREFIX_.'product_sale (`id_product`, `quantity`, `sale_nbr`, `date_upd`) VALUES ('.(int)($product_id).', '.(float)($qty).', 1, NOW()) ON DUPLICATE KEY UPDATE `quantity` = `quantity` + '.(float)($qty).', `sale_nbr` = `sale_nbr` + 1, `date_upd` = NOW()' ); // check remaining product quantity subsequent to the sale transaction and, if sold out, set product.active=0 (aka disabled/draft, does not display in catalog) $smurf = Db::getInstance()->getValue('SELECT `quantity` from `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$product_id); if ($smurf <= 0 ) { Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product` SET `active` ='. (int)0 .' WHERE `id_product` = '.(int)$product_id); } return $goober; } } ?> that worked for me on 1.4 THANK YOU! works for me in PS 1.4.6.2 Note: it only works when a customer buy the last product, not when you change the quantity to 0 manually. Link to comment Share on other sites More sharing options...
jakoushirou Posted September 1, 2012 Share Posted September 1, 2012 (edited) Is there something else what I have to do ? Only put the file in /override/classes Please is there anybody who can help me. I need it for my webshop. I know that it is been a while, but maybe someone will need it It works only when customer buy last product, then payment must be accepted and product must be sent. When all this condiotion are checked, product is disable. It works for me in PS 1.4.4.1 Edited September 1, 2012 by jakoushirou (see edit history) Link to comment Share on other sites More sharing options...
dimam Posted October 1, 2012 Share Posted October 1, 2012 I know that it is been a while, but maybe someone will need it It works only when customer buy last product, then payment must be accepted and product must be sent. When all this condiotion are checked, product is disable. It works for me in PS 1.4.4.1 Works in 1.4.9 with same conditions (payment accepted and product shipped) Thank you for the tip!! DimaM Link to comment Share on other sites More sharing options...
El Patron Posted August 24, 2013 Share Posted August 24, 2013 The wait is over...at least for ps v1.4 shops. Note: 1.5 version in testing so make sure to follow this link below to be notified. http://www.prestashop.com/forums/topic/269988-module-hide-out-of-stock-products-prestashop-v14/page__pid__1350848#entry1350848 Link to comment Share on other sites More sharing options...
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