MySQL query to retrieve newly added products from magento database category wise

Go To StackoverFlow.com

0

I have created one custom drop down attribute with value 'yes' or 'on'. Now my question is how can we write a MySQL query to retrieve newly added products in category wise which are checked 'yes' by using custom attribute for MySQL database and where we have to place that query? Here I want to display these newly added products on home page category wise.

2012-04-04 07:05
by kranthi


1

You want to do it inside Magento? Use collections instead.

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*'); // Or only the attributes that you need
$collection->addAttributeToFilter('your_attribute', array('eq' => '1'));

foreach ($collection as $product) {
    echo $product->getId();
}
2012-04-04 11:58
by Rafael Kassner
HI Rafael thank you very much for your reply but i think by using your code we can get the product which status is '1' but i want to replace automatically recently added products whose custom attribute status in '1' with old items how - kranthi 2012-04-05 10:53
You can filter by newsfromdate and newstodate attribute, applying a one-month range, for example. Of course, you can combine more than one attribute filter. Read more about Magento Collections: http://www.magentocommerce.com/wiki/1-installationandconfiguration/usingcollectionsin_magent - Rafael Kassner 2012-04-05 13:47
Ads