2

On Magento 1.9 I have a category page with produts and static block.

For static block I used a block type="catalog/product_list with a custom template. In the html template I loaded a custom productCollection to filter on a specific category (different from category page).

<?php
$_productCollection = Mage::getModel('catalog/product')->getCollection()
->joinField('category_id','catalog/category_product','category_id','product_id=entity_id',null,'left')
->joinField('rating_summary', 'review/review_aggregate', 'rating_summary', 'entity_pk_value=entity_id',  array('entity_type' => 1, 'store_id' => Mage::app()->getStore()->getId()), 'left');
$_productCollection->addAttributeToSelect(array(
                                   'image',
                                   'small_image',
                                   'name',
                                   'short_description',
                                   'rotator_image',
                                   'formato',
                                   'author', 
                                   'artist', 
                                   'regista', 
                                   'formato', 
                                   'showpercdiscount',
                                   'sort_order'
                   ))
                   ->addFieldToFilter('visibility', array(
                               Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                               Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                   )) //showing just products visible in catalog or both search and catalog
                   ->addFinalPrice()
                   ->addAttributeToFilter('category_id', '498')
//                   ->addAttributeToFilter('attribute_set_id','9')
                   ->addAttributeToSort('sort_order', 'asc') //in case we would like to sort products by price
                   ->getSelect()
//                   ->where('price_index.final_price < price_index.price')
                   ->limit(8) //we can specify how many products we want to show on this page
//                        ->order(new Zend_Db_Expr('RAND()')) //in case we would like to sort products randomly
                   ;

Mage::getModel('review/review')->appendSummary($_productCollection);

$_helper = $this->helper('catalog/output');
?>

When I try to sort, change pagination or use layered navigation, Magento changes also the product list in the static block. Why?

  • stackoverflow.com/a/28444299/158325 You'll need to adjust the layer model as well which is keep track of session, filter options, settings, etc. – B00MER Oct 3 '18 at 19:14
  • try renaming your custom product collection Replace '$_productCollection' with '$customProductCollection' or sth – Yiorgos Moschovitis Oct 4 '18 at 15:27
  • @YiorgosMoschovitis: I tried with $_productCollection2 with no success – domfitty Oct 5 '18 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.