brownd92 Posted October 18, 2013 Share Posted October 18, 2013 Hi there, Is there any way of only showing products in stock? Thanks Link to comment Share on other sites More sharing options...
vekia Posted October 18, 2013 Share Posted October 18, 2013 by default it isn't. all that you are able to do is to change controllers (to select products only in stock) or aply some triggers (disable out of stock product mysql trigger) or use some module automatically hide oos products http://www.prestashop.com/forums/topic/269988-module-automatically-hide-out-of-stock-products-v14-15/ Link to comment Share on other sites More sharing options...
Htiti Chihab Eddine Posted January 28, 2016 Share Posted January 28, 2016 (edited) This question was asked so many times and no one offered a solution so here is a basic simple one that i think works fine with 1.6 : P.S : This solution doesnt work With products randomizedStep 1 : go to Modules/homefeatured/homefeatured.php - Look for : if (Configuration::get('HOME_FEATURED_RANDOMIZE')) HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), null, null, false, true, true, ($nb ? $nb : 8)); else HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), 'position'); } Replace with : if (Configuration::get('HOME_FEATURED_RANDOMIZE')) HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), 'quantity', 'DESC', false, true, true, ($nb ? $nb : 8)); else HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), 'quantity','DESC'); } Step 2 : Go to Product-list.tpl - At the end of the <li class="ajax_block_product.............. before you close the li add this code : style="{if $page_name=='index' && $product.quantity < 1 }display:none{/if}" Ex : <li class="ajax_block_product.LONGBLALALALALA" style="{if $page_name=='index' && $product.quantity < 1 }display:none{/if}"> And Voila ! you'll get Only in stock products in home featured EXTRA : Basicaly what it does is show product list ordered by Quantity so it first shows Products that are in stock and at the end it adds the products that arent . And all i do is hide these products at the end and it doesnt not affect the order of products nor the Css style... EXTRA 2 : If you want to do the same thing on Category pages all you have to do is : STEP 3 : go to controllers/front/CategoryController.php - Look for : if (!$hookExecuted) { $this->context->smarty->assign('categoryNameComplement', ''); $this->nbProducts = $this->category->getProducts(null, null, null, $this->orderBy, $this->orderWay, true); $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts" $this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); } Replace with : if (!$hookExecuted) { $this->context->smarty->assign('categoryNameComplement', ''); $this->nbProducts = $this->category->getProducts(null, null, null, 'quantity', 'DESC', true); $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts" $this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, 'quantity', 'DESC'); } REPLACE STEP 2 WITH THIS ONE : Go to Product-list.tpl - At the end of the <li class="ajax_block_product.............. before you close the li add this code : style="{if $product.quantity < 1 }display:none{/if}" Ex : <li class="ajax_block_product.LONGBLALALALALA" style="{if $page_name=='index' && $product.quantity < 1 }display:none{/if}"> AND VOILA 2 forgive my english hope this helps Edited January 28, 2016 by Htiti Chihab Eddine (see edit history) Link to comment Share on other sites More sharing options...
Sasni Posted September 11, 2016 Share Posted September 11, 2016 In \classes\Category.php change WHERE product_shop.`id_shop` = '.(int)$context->shop->id.' to WHERE stock.`quantity` > 0 AND product_shop.`id_shop` = '.(int)$context->shop->id.' Link to comment Share on other sites More sharing options...
MaxV2019 Posted March 12, 2020 Share Posted March 12, 2020 This free module should resolve all: https://www.sunnytoo.com/31746/hiding-stock-products-free-prestashop-module Link to comment Share on other sites More sharing options...
El Patron Posted March 14, 2020 Share Posted March 14, 2020 anyone reading this should consider the seo implications which I suppose are only relevant if the product never comes back into stock. if it does then what are the implications? anyone can write a hack/module to do 'something' but that does not mean it's always a good idea. happy selling Link to comment Share on other sites More sharing options...
MaxV2019 Posted March 16, 2020 Share Posted March 16, 2020 Our test of 6 months showed that the 90-99% of on-line buyer wants only products ready on stock, so showing products with no stock is only counterproductive. Link to comment Share on other sites More sharing options...
El Patron Posted March 16, 2020 Share Posted March 16, 2020 4 hours ago, MaxV2019 said: Our test of 6 months showed that the 90-99% of on-line buyer wants only products ready on stock, so showing products with no stock is only counterproductive. well granted we don't want to be shown 'out of stock' products unless it supports capability to notify us but if you have products that come and go out of stock what then is your answer on hiding temporarily out of stock item and organic seo. again it's easy to blanket justify to do something but I challenge that it's not a good idea unless that product has 1) really long restock delay 2) is never going to be sold again, in either case the 404 should be handled elegant. There is difference between low end shops that implement something that 'can be done' but is not always perfectly thought out. 1 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