문제

I've enabled flat tables. Now the new arrival products aren't appearing which is filtered by a particular category. Below code works when flat tables are disabled.

$cat = Mage::registry('current_category'); 
    $catid = $cat->getId();
    $_products = $this->getProductCollection()
                      ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
                      ->addAttributeToFilter('category_id', $catid);

Is there a different way to get new arrivals product filtered by a particular category when flat tables are ON?

도움이 되었습니까?

해결책 2

I was able to get new product collection and filter by category using below code

$cat = Mage::registry('current_category'); 
$catid = $cat->getId();
$_products = $this->getProductCollection();
$category = Mage::getModel('catalog/category')->load($catid);
$_products->addCategoryFilter($category);

다른 팁

You can try this,

$collection = Mage::getModel('catalog/category')
                    ->load($categoryId)
                    ->getProductCollection();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top