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
    Nov 25 '16 at 10:01
  • I just noticed this comment now. Well,I would love to display under the compare list.
    – Shota
    Nov 28 '16 at 5:23
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
    Nov 28 '16 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
    Nov 28 '16 at 3:03
  • check if product has related products assigned or not?
    – Piyush
    Nov 28 '16 at 5:54
  • Yes,already have done it.
    – Shota
    Nov 28 '16 at 6:22
  • Where should I put "<?php echo $this->getChildHtml('catalog.product.related') ?>" in "view.phtml"?
    – Shota
    Nov 28 '16 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
    Nov 28 '16 at 1:48
  • Yes & be sure to replace $_product with your product object. Nov 29 '16 at 9:08
  • Which files should I put it in?
    – Shota
    Nov 30 '16 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 :) Nov 30 '16 at 9:30
  • I just put it there.However it shows just code like $related_products =.....
    – Shota
    Dec 1 '16 at 0:36

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.