cancel
Showing results for 
Search instead for 
Did you mean: 

Best Way to create category page with "New In" products

Best Way to create category page with "New In" products

I need to create a new category page which list all products added by past 7 days , that page should act like a normal category page with the layered Navigation (I'm using AITOC layered navigation) but with products added in past week . What is the best method to do this ? . I can get the prouct collection of products added in last 7 days and then create a new cms page and point my collection to it but it will not include pagination layered navigation etc... so there should be a better method to do this 

_______________________________________________
An Expert in Anything Was Once a Beginner
5 REPLIES 5

Re: Best Way to create category page with "New In" products

Hi Chamal,

 

You can realize this within the same category by adding a new URL parameter ?filter=week.

 

Get this parameter in 

/app/code/local/AdjustWare/Nav/Model/Observer.php

and add a condition to product collection by adding after this line 

$configurableProducts = array_unique($configurableProducts);

the following code

if(Mage::app()->getRequest()->getParam('filter') == 'week')
{
    $collection->getSelect()->where('created_at > NOW() - INTERVAL 7 DAY');
}

 

Besides, you will need to add analogous conditions for setbar filters to the following files 

/app/code/local/AdjustWare/Nav/Model/Catalog/Layer/Filter/Attribute.php

/app/code/local/AdjustWare/Nav/Model/Catalog/Layer/Filter/Price.php

 

Hope this helps!

 


Aitoc is a group of distinguished web developers that have been building for Magento since 2009.
See our extensions for Magento 2.

Re: Best Way to create category page with "New In" products

thank you very much for replying to my question ,but I need to achive this in a complete new category not in a same category any suggestion for it ?

_______________________________________________
An Expert in Anything Was Once a Beginner

Re: Best Way to create category page with "New In" products

Hi Chamal,

In this case you can use pretty much the same piece of code.

The only difference would be, you don't have to add the parameter to the URL.

You should check right from the start whether an additional condition should be applied to this category. In this array $categoryIds , you'd then need to write the categories that require the additional condition.

if(in_array(Mage::registry('current_category')->getId(), $categoryIds))
{
    $collection->getSelect()->where('created_at > NOW() - INTERVAL 7 DAY');
}

 


Aitoc is a group of distinguished web developers that have been building for Magento since 2009.
See our extensions for Magento 2.

Re: Best Way to create category page with "New In" products

I have tried what you described but couldn't find a place to add the condition in following files.

/app/code/local/AdjustWare/Nav/Model/Catalog/Layer/Filter/Attribute.php

/app/code/local/AdjustWare/Nav/Model/Catalog/Layer/Filter/Price.php

 

where to add above condition in Attribute.php and Price.php . So far I have added condition to Observer.php only but it is not showing any results , please help me.

 

to mention I have no products already added to above category and need to display products from a custom collection no need to adding products to the category 

_______________________________________________
An Expert in Anything Was Once a Beginner

Re: Best Way to create category page with "New In" products

/app/code/local/AdjustWare/Nav/Model/Catalog/Layer/Filter/Attribute.php
function _getBaseCollectionSql
/app/code/local/AdjustWare/Nav/Model/Catalog/Layer/Filter/Price.php
function getMinOrMax

 

If you use custom collection then the code should be added to this collection, not to the category's collection.

If you'll have further questions, you can contact support on our website. 

 

 


Aitoc is a group of distinguished web developers that have been building for Magento since 2009.
See our extensions for Magento 2.