Hope somebody can help me out here.
What I'm try to do, is to show related products, when you're landing on a products page.
Let's say:
I have a categori, the name is computer. In that computer category, I have 3 products a Acer laptop, a HP laptop and a Apple macbook air.
If my customer click on the mac - how can I then show the related products? (eg. the Acer and the HP laptop).
I don't want to edit the catelog.xml - allready tryed that, whitout any luck.
I allready got som php file
- And it sort-of working, but when the customer lands on one of the product page, they also sees the product, that they're reading about - how can I remove the current product from the list?
<?php
$currentCategoryId = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
$product_id = $this->getProduct()->getId();
echo $product_id;
$categoryid = $currentCategoryId;
$category = new Mage_Catalog_Model_Category();
$category->load($categoryid);
$collection = $category->getProductCollection();
$collection->addAttributeToSelect('*');
foreach ($collection as $_product) { ?>
<a href="<?php echo $_product->getProductUrl(); ?>"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(200); ?>" width="200" height="200" alt="" /></a> <a href="<?php echo $_product->getProductUrl(); ?>"><?php echo $_product->getName(); ?></a>
<?php } ?>
It takes all the products from the entire category, and then displays them on the current productpage.
I really hope someone can help me out.