kranthi
kranthi

Reputation: 59

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

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.

Upvotes: 0

Views: 678

Answers (1)

Rafael Kassner
Rafael Kassner

Reputation: 1124

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();
}

Upvotes: 1

Related Questions