I want to display a
product-page, if the product got upsell products.
What is the condition that I need to check for this?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
You can try this.
<?php $_product = $this->getProduct(); ?> <?php if (count($_product->getUpSellProductIds()) > 0) : ?> <!-- your list should come inside this condition--> <ul> <li>item-1</list> <li>item-2</list> <li>item-3</list> </ul> <?php endif; ?>
If you have a valid product object on
getUpSellProductIds() will provides you an array of upsell product ids related to the product which holds by
$_product. So what we are doing here is checking whether the array count is greater than zero. If it is yes, then shows the list.
Hope you get the concept.
This is simple. In your
view.phtml file write this code where your want to display "li" or any HTML code:
Also you can use
$upsell_products in a
foreach() loop to get each product and attributes.