I want to show products in same category withing single product page. see bellow diagram what i want to achieve live site example please see this site [https://www.jackthreads.com/goodale/shirts/rutledge-navywhite-plaid-shirt/products/170189][1] for more idea. i want to know how it achieve?


Try this code in your view.phtml

$productId = $_product->getId();
$productCollection = Mage::getModel('catalog/product')->load($productId);
$catIds = $productCollection->getCategoryIds();
 foreach ($catIds as $categoryId) {
    $_productCollection = Mage::getModel('catalog/category')->load($categoryId)
            ->addAttributeToFilter('status', 1)
            ->addAttributeToFilter('visibility', 4);
            foreach($_productCollection as $catProducts){
                echo    $catProducts->getName();
                echo '<br>';
                    // get your product here 


  • @Srinath I have updated and tested my code it's working fine plz check it. – Arunendra Sep 15 '15 at 5:04
  • it gives fatal error getId() – srinath madusanka Sep 15 '15 at 5:04
  • Please use updated code – Arunendra Sep 15 '15 at 5:12

you can achieve this with below code..

    <?php $cats = $_product->getCategoryIds(); 
foreach ($cats as $category_id) {
    $category_id; exit;
   $products = Mage::getModel('catalog/category')->load($category_id)
; //sets the order by price

  • please give me some time to check it. – srinath madusanka Sep 15 '15 at 4:07
  • where i add view.pthml file or controller file – srinath madusanka Sep 15 '15 at 4:13
  • you can add in view.phtml – Qaisar Satti Sep 15 '15 at 4:31
  • it give me null array object(Mage_Catalog_Model_Product)#931 (32) { ["_cacheTag":protected]=> string(15) "catalog_product" ["_eventPrefix":protected]=> string(15) "catalog_product" ["_eventObject":protected]=> string(7) "product" ["_canAffectOptions":protected]=> bool(false) ["_typeInstance":protected]=> NULL ["_typeInstanceSingleton":protected]=> NULL ["_linkInstance":protected]=> NULL ["_customOptions":protected]=> array(0) { } ["_urlModel":protected]=> NULL ["_errors":protected]=> array(0) { } ["_optionInstance":protected]=> NULL – srinath madusanka Sep 15 '15 at 4:40
  • 1
    issue not solve but it can get category ids i dont know it is my issue. i up voted answer thank you helping – srinath madusanka Sep 15 '15 at 5:20

The Magento way of doing this is to add related product for individual Product from admin Panel

Catalog > Manage Products > Choose the Product to Edit > select the related Product tab > and choose the relevent Product(s) you want to show on Product Page

I now it is time consuming Process but you can show more relevant products and increase the sales.

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.