Skip to main content
added 7 characters in body
Source Link

I want to add a product to a category page depending on the category IDcategory ID. This product is not part of the category.

In Mage_Catalog_Block_Product_List I see the following line:

$category = Mage::getModel('catalog/category')->load($this->getCategoryId());

Would it be possible to have an if underneath? - Is this the right place?

$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
if ($this->getCategoryId() == 123) {
  //add product id 456 to the collection
}

If so, how do I add a product to the $category collection? 

And further to this, is it possible to insert it in a particular place, lets say inbetween the 3rd and 4th product?

I want to add a product to a category page depending on the category ID. This product is not part of the category.

In Mage_Catalog_Block_Product_List I see the following line:

$category = Mage::getModel('catalog/category')->load($this->getCategoryId());

Would it be possible to have an if underneath? - Is this the right place?

$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
if ($this->getCategoryId() == 123) {
  //add product id 456 to the collection
}

If so, how do I add a product to the $category collection? And further to this, is it possible to insert it in a particular place, lets say inbetween the 3rd and 4th product?

I want to add a product to a category page depending on the category ID. This product is not part of the category.

In Mage_Catalog_Block_Product_List I see the following line:

$category = Mage::getModel('catalog/category')->load($this->getCategoryId());

Would it be possible to have an if underneath? - Is this the right place?

$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
if ($this->getCategoryId() == 123) {
  //add product id 456 to the collection
}

If so, how do I add a product to the $category collection? 

And further to this, is it possible to insert it in a particular place, lets say inbetween the 3rd and 4th product?

Source Link
Lee
  • 183
  • 9

1.9 - Add product to category collection by ID

I want to add a product to a category page depending on the category ID. This product is not part of the category.

In Mage_Catalog_Block_Product_List I see the following line:

$category = Mage::getModel('catalog/category')->load($this->getCategoryId());

Would it be possible to have an if underneath? - Is this the right place?

$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
if ($this->getCategoryId() == 123) {
  //add product id 456 to the collection
}

If so, how do I add a product to the $category collection? And further to this, is it possible to insert it in a particular place, lets say inbetween the 3rd and 4th product?