2

I am trying to display only the products that are on sale using the following code but instead of only displaying the one product I have on sale, it is displaying all my products. Please can someone tell me what is wrong with my code.

I am testing using Expression Engine 2.7.1 and Expresso Store 2.0.6

{exp:store:search channel="products" search:on_sale="yes" }

        {title}

{/exp:store:search}
1

The search:on_sale="yes" parameter hasn't been implemented in Store 2 yet, due to the complexity of the new global sales functionality.

To mimic this behaviour you should be able to use the on_sale conditional like so:

{exp:store:search channel="products"}
    {if product_details:on_sale}
        <!-- product details -->
    {/if}
{/exp:store:search}

This parameter will be added back in the next version of Store 2.

| improve this answer | |
  • Does this mean ALL products are fetched from the database then filtered? So if you have 100,000 products they all get fetched then the ones on sale get filtered using PHP? There could be quite a performance issue with large databases. – Laurence Cope Nov 19 '13 at 19:55
  • Yes, although 100,000 is really an edge case :) We had to do some extra work to make this happen in a memory-efficient way (due to the complexity of the new sale options), which is why this didn't make the 2.0 release. However, it's finished now and will be included in the next release. – Adrian Macneil Nov 19 '13 at 21:05
  • I know :) I dont have that many but someone might! I have this issue with Brilliant Retail, it does the same for Featured products, it bugs me, so looking forward to the next release. – Laurence Cope Nov 20 '13 at 8:19
0

The Store tag needs to go inside a Channel entries tag, something like this...

{exp:channel:entries channel="products"}
{exp:store:product}
  {if on_sale}
  {title}
  Price: <del>{regular_price}</del> <ins>{price}</ins>!
  {/if}
{/exp:store:product}
{/exp:channel:entries
| improve this answer | |
  • The search tag acts a wrapper for the channel entries tag and you should not use it nested inside of a regular channel entries tag because it will provide weird results unless you were going to use an embedded template which could very easily become a huge performance hit if you have more then a few products on each page load. – Justin Long Nov 17 '13 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.