Get Upsell products list using Product Id in Magento
In some situation when you need to show product in custom location file and in that file you also want to show list of upsell product then this is example which will explain you.
For Example : Suppose you have Product ID and using that ID you want to accees upsell product list then you can use following code :
1. Assume that you have product ID is : $product_id
2. Using that ID you can get list of Upsell product. Copy following code and place it in you custom file.
<?php // Get product object. $object = Mage::getModel('catalog/product'); //Get product detail using product id (Suppose you have product id is : $product_id) $_product = $object->load($product_id); // Fetch list of upsell product using query. $upsell_product = $_product->getUpSellProductCollection()->addAttributeToSort('position', Varien_Db_Select::SQL_ASC)->addStoreFilter(); //check if record is empty or not $count = count($upsell_product); if(empty($count)) : //if empty echo "Record not found"; else: //if result is not empty then get upsell product detail using foreach loop foreach($upsell_product as $_upsell): //get detail of single upsell prdocut using upsell product id $upsp = $object->load($_upsell->getId()); echo "Product Name : ". $upsp->getName(); echo "Poduct url : ". $upsp->getProductUrl(); echo "Product regular price : ". $upsp->getPrice(); endforeach; endif; ?>
3. Done
Such a nice post……keep posting…….:)
It works for me.
thanks
Thanks for your comments….
We have made the decision to open our POWERFUL and PRIVATE website traffic system to the public for a limited time! You can sign up for our UP SCALE network with a free trial as we get started with the public’s orders. Imagine how your bank account will look when your website gets the traffic it needs. Visit us today: http://v.af/o8l