2026 Executive BenchmarkMid-Market Enterprise Modernization: How leaders across unify Commerce, Odoo ERP & AI in 90 days.
MAGENTO COMMERCE

Show sell product filter by category id in magento

Create a new CMS Block with content set to CMS Block, by going to CMS > Static Blocks, which we will name it as Specials. In the Content tab of that Page, paste the below line of c...

Akshar Group Technologies
Dec 25, 2020
1 min read
Verified Source

Create a new CMS Block with content set to CMS Block, by going to CMS > Static Blocks, which we will name it as Specials. In the Content tab of that Page, paste the below line of code:

code
{{block type="catalog/product" template="catalog/product/yourfile.phtml"}}
create file app/design/frontend/default/YOUR_THEME/template/catalog/product/yourfile.phtml and past following code.
php
<scirpt>

getCurrentCategory()->getId();
$category = Mage::getModel('catalog/category')->load($categoryid);
$collection = $category->getProductCollection();

$todayDate = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y'));
$tomorrowDate = date('m/d/y', $tomorrow);

Mage::getModel('catalog/layer')->prepareProductCollection($collection);
$collection->addAttributeToSort('created_at', 'desc');
$collection->addStoreFilter();

$collection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $tomorrowDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left');

//$_productCollection->printLogQuery(true)

?>

</script>
Share this playbook
LET'S BUILD WHAT'S NEXT

What's Holding Your Business Back?

Tell us where you want to go, what's getting in the way, and we'll help you figure out the technology to get there.

No sales pitch. Confidential strategic advisory.