Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Show all products in the same category - rather than related products - on product view page
 
hez
Sr. Member
 
Avatar
Total Posts:  103
Joined:  2008-02-02
 

Hi,

Just wondering if it was possible to show all products in the same category on the product view page, rather than the ‘related products’. 

Here’s what I think I need to do.

1. Create a duplicate of the catalogue\product\list\related.phtml in my local directory and rename it to something like categories.phtml
2. Change that file to get the category listing.  I think that must be froom line 58 but I’m not sure how to get the categories rather than related.

function selectAllRelated(){
    
$$('.related-checkbox').each(function(elem){
        elem
.checked true;
    
});
    
addRelatedToProduct();
}

function addRelatedToProduct(){
    
var checkboxes = $$('.related-checkbox');
    var 
values [];
    for(var 
i=0;i<checkboxes.length;i++){
        
if(checkboxes[i].checkedvalues.push(checkboxes[i].value);
    
}
    
if($('related-products-field')){
        
$('related-products-field').value values.join(',');
    
}
}

3. in layout\catalogue.xlm change the line at 138 from

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

to

<block type="catalog/product_list_categories" name="catalog.product.categories" before="-" template="catalog/product/list/categories.phtml"/>

But I’m just taking a shot in the dark here and feel like I might also be missing a step.

Heck - I could be waaaay off base and there’s a much easier way to do this.

Any ideas?

Thanks,
Hez

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

In latest release it is possible to show block catalog/product_list on product view page, and it will take the category of a product.
You your own template, and put this into Custom Layout Update on your product if you want this for specific product, or add it to layout update file into <catalog_product_view> handle for all products:

<reference name="content">
  <
block type="catalog/product_list" name="same_category_products" template="my_custom_template.phtml"/>
</
reference>
 
Magento Community Magento Community
Magento Community
Magento Community
 
seoguy
Member
 
Total Posts:  46
Joined:  2008-01-25
 

Hey Moshe.

Any way to limit the number of products it pulls from the category?  Any way to have products from the same category pulled randomly?

Basically, I want to display 3 products located in the same category to be pulled randomly.

Thanks

Chris

 
Magento Community Magento Community
Magento Community
Magento Community
 
hez
Sr. Member
 
Avatar
Total Posts:  103
Joined:  2008-02-02
 

Sorry Moshe - I don’t quite follow - still trying to get my head wrapped around this.

I want this to be on all products (and I want to show all items in the category)

I get that I need to add the code into the <catalogue_product_view> section of the layout/catalogue.xml file.

What I don’t understand, is what the template my_custom_template.phtml should contain. 

Thanks for your help.

Heather

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top