1

I am using magento ver1.9.2 and GPMD.

I would love to ask that how to show related products on GPMD theme.I was able to show it when I use default one.However I cannot now.

I think I should put or rename some files.Do you have some tips or know how to do?I want to know it.That would be so helpful to me.

2
  • where do you want to display related product?
    – Piyush
    Commented Nov 25, 2016 at 10:01
  • I just noticed this comment now. Well,I would love to display under the compare list.
    – Shota
    Commented Nov 28, 2016 at 5:23

2 Answers 2

0

If you want to display related products in Product view page Try adding

<block type="catalog/product_list_related" name="catalog.product.related" as="related" template="catalog/product/list/related.phtml"/>

under the

<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">

like below in the catalog.xml

<reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
            <block type="catalog/product_list_related" name="catalog.product.related" as="related" template="catalog/product/list/related.phtml"/>
</block>

and in your themes product view.phtml

add code

<?php echo $this->getChildHtml('catalog.product.related') ?>

where you want to display related products

18
  • Hello Piyush, Could you please tell me more?I could find "catalog.xml" and add the 1st one under the 2nd one. Then should I add the 3rd one in "view.phtml"?And where should I put 4th one in? Anyways thanks for giving tips,your tips would help me.
    – Shota
    Commented Nov 28, 2016 at 1:44
  • I'm sorry but I misunderstood, I should add first one under the second one.And then,I should add 4th one in "view.phtml".Right? But it does not exist in products page..
    – Shota
    Commented Nov 28, 2016 at 3:03
  • check if product has related products assigned or not?
    – Piyush
    Commented Nov 28, 2016 at 5:54
  • Yes,already have done it.
    – Shota
    Commented Nov 28, 2016 at 6:22
  • Where should I put "<?php echo $this->getChildHtml('catalog.product.related') ?>" in "view.phtml"?
    – Shota
    Commented Nov 28, 2016 at 6:24
0

No idea about this theme coding.

But below code you can add wherever you want to show related products of the product. Here $_product is the product you want to show related products.

$related_products = Mage::getModel('catalog/product')
                  ->getCollection()
                  ->addAttributeToSelect('name')
                  ->addAttributeToSelect('sku')
                  ->addAttributeToFilter('entity_id',array('in'=>$_product->getRelatedProductIds()));
     foreach($related_prods as $related){
      echo $related->getName(); 
              } 
6
  • Thank you for giving a tip,Akhil. Should I add it in just a phtml file?
    – Shota
    Commented Nov 28, 2016 at 1:48
  • Yes & be sure to replace $_product with your product object. Commented Nov 29, 2016 at 9:08
  • Which files should I put it in?
    – Shota
    Commented Nov 30, 2016 at 0:29
  • In GPMD theme if want to show in product page then put in: /app/design/frontend/YOUR_THEME/template/catalog/product/view.phtml & later move this code where design looks fine. Development UI experience will be required. If helps feel free to upvote the answer :) Commented Nov 30, 2016 at 9:30
  • I just put it there.However it shows just code like $related_products =.....
    – Shota
    Commented Dec 1, 2016 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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