Jump to content

Want to show "More Sizes Available" on product-list, if a product has combinations


bhaskey

Recommended Posts

I am using PS 1.6.0.14.

I have been trying to show "More Sizes Available" on product-list, if a product has combinations. Tries following in product-list.tpl

{if (!isset($product.combinations) && $product.combinations > 0)}

Tried many other similar conditions but no luck, I could not accomplish the desired.

 

Could someone please hint me what would be the correct condition.

Edited by bhaskey (see edit history)
Link to comment
Share on other sites

!isset is checking that the variable doesn't exist, so that will be doing the opposite of what you're after. Assuming the variable does indeed exist, this code should do the job:

{if !empty($product.combinations)}

That is a function which checks if a variable exists and that it isn't empty (bool false, numeric 0, empty array, etc).

If you wanted to be a bit more specific to check that it's an array, you could use:

{if (isset($product.combinations) && is_array($product.combinations) && count($product.combinations) > 0)}
Link to comment
Share on other sites

Ah, apologies, I didn't spot the product list bit, hmm, I think it isn't available there, no.

 

Would be a bit more involved in that case, you'd need to set up an override file for the front categoryController, then alter the function which returns the product list, called assignProductList, to include an sql query that checks if there are combinations and returns a true/false value.

 

Hmm, actually, checking the query, you might be able to just check if $product.id_product_attribute > 0 .. I think it tries to grab one of the combinations if it can, so that in theory should confirm the existence of them

  • Like 2
Link to comment
Share on other sites

Needed to assign a variable to smarty. 

 

Solved by creating a small module and hooked it into project-list.tpl. Thanks FullCircles for your help.

 

I will share the module shortly, so maybe someone else could be benifited.

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

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...