Jump to content

View product list


rotsyweb

Recommended Posts

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

  • 2 weeks later...

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

  • 8 months later...

"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?

 

  • Like 1
Link to comment
Share on other sites

  • 7 months later...
  • 9 months later...
  • 5 weeks later...

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 by 2byte (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...