rotsyweb Posted January 30, 2018 Share Posted January 30, 2018 Hello,I use prestashop 1.7 recently.and what I would like to know if we can on the display products not displayed only products that in stock (with quantity> 0)In product-I already added the code: {if $ product.quantity> 0} {/ if}but it still does not work.Do you have an idea please?Available,Here's the whole code for product-list.tpl:{extends file = $ layout}{block name = 'content'} <section id = "main"> {block name = 'product_list_header'} <h2 class = "h2"> {$ listing.label} </ h2> {/ Block} <section id = "products"> {if $ listing.products | count}{if $ product.quantity> 0} <div id = ""> {block name = 'product_list_top'} {include file = 'catalog / _partials / products-top.tpl' listing = $ listing} {/ Block} </ Div> {block name = 'product_list_active_filters'} <div id = "" class = "hidden-sm-down"> {$ listing.rendered_active_filters nofilter} </ Div> {/ Block} <div id = ""> {block name = 'product_list'} {include file = 'catalog / _partials / products.tpl' listing = $ listing} {/ Block} </ Div> <div id = "js-product-list-bottom"> {block name = 'product_list_bottom'} {include file = 'catalog / _partials / products-bottom.tpl' listing = $ listing} {/ Block} </ Div> {Else} {include file = 'errors / not-found.tpl'}{/ If} {/ If} </ Section> </ Section>{/ Block} Link to comment Share on other sites More sharing options...
Andrej Stas Posted February 11, 2018 Share Posted February 11, 2018 Your solution doesn't work because $product is not defined in this file. You need to go to /your_theme/catalog/_partials/miniatures/product.tpl and add this code: {block name='product_miniature_item'} {if $product.quantity > 0} ..... {/if} {/block} This solution is simple, but not ideal if you have many products out of stock. The "out of stock" products will not be displayed in the category view, but they will be still considered in the calculation of the pagination. Link to comment Share on other sites More sharing options...
Fabio Manzo Posted October 24, 2018 Share Posted October 24, 2018 "This solution is simple, but not ideal" On 2/11/2018 at 9:01 AM, Andrej Stas said: Your solution doesn't work because $product is not defined in this file. You need to go to /your_theme/catalog/_partials/miniatures/product.tpl and add this code: {block name='product_miniature_item'} {if $product.quantity > 0} ..... {/if} {/block} This solution is simple, but not ideal if you have many products out of stock. The "out of stock" products will not be displayed in the category view, but they will be still considered in the calculation of the pagination. Exactly. So how can I operate on the query? I can't find the query responsible for listing products in a category, Where is it? 1 Link to comment Share on other sites More sharing options...
Darius1990 Posted June 18, 2019 Share Posted June 18, 2019 same problem. Link to comment Share on other sites More sharing options...
Damien DELEYE Posted March 19, 2020 Share Posted March 19, 2020 hi, same problem too Link to comment Share on other sites More sharing options...
kitchen007 Posted April 18, 2020 Share Posted April 18, 2020 same problem.. have.. you find any solution .. can anyone tell where is query responsible for listing products in a category?? Link to comment Share on other sites More sharing options...
2byte Posted April 25, 2020 Share Posted April 25, 2020 (edited) Yes, this is the question, I think that ps should list product from the category selected, not listing all products that are in some parent category or children categories. For example, I have this tree category: - CAT A - - CAT A1 - - - CAT A2 - - - - CAT A3 And I have a product called PRODUCT A3, and this product have selected only the CAT3 category. Then, I we go to listing category in frontend CAT A,CAT A1 or CAT A2, here you can see in the bottom list the product CAT3. I think it´s not correct, before it not happened in pestashop. The reason is that in YOUR_THEME/templates/catalog/listing/product-list.tpl <section id="products"> {if $listing.products|count} ---------> >1 .Not list the category selected and count products, it count all products in all categories. How can change the products count in the category selected? Thanks. Edited April 25, 2020 by 2byte (see edit history) 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