It seems that many of the custom attributes that i've created aren't present in the product collection that i'm producing. How do I add more of them? This is the method I use to get the new product collection.

protected function _getProductCollection()
    $todayStartOfDayDate = Mage::app()->getLocale()->date()
    $todayEndOfDayDate = Mage::app()->getLocale()->date()
    /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
    //$collection = Mage::getModel('catalog/product')->getCollection()
    $collection = Mage::getResourceModel('catalog/product_collection');
    $collection = $this->_addProductAttributesAndPrices($collection)
        ->addAttributeToFilter('news_from_date', array('or' => array(
            0 => array('date' => true, 'to' => $todayEndOfDayDate),
            1 => array('is' => new Zend_Db_Expr('null')))
        ), 'left')
        ->addAttributeToFilter('news_to_date', array('or' => array(
            0 => array('date' => true, 'from' => $todayStartOfDayDate),
            1 => array('is' => new Zend_Db_Expr('null')))
        ), 'left')
                array('attribute' => 'news_from_date', 'is' => new Zend_Db_Expr('not null')),
                array('attribute' => 'news_to_date', 'is' => new Zend_Db_Expr('not null'))
    return $collection;

The resultant __tostring() of the collection looks like this:

SELECT 1 AS status, e.entity_id, e.type_id, e.attribute_set_id, cat_index.position AS cat_index_position, price_index.price, price_index.tax_class_id, price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price, e.name, e.short_description, e.price, e.special_price, e.special_from_date, e.special_to_date, e.small_image, e.thumbnail, e.news_from_date, e.news_to_date, e.url_key, e.required_options, e.image_label, e.small_image_label, e.thumbnail_label, e.msrp_enabled, e.msrp_display_actual_price_type, e.msrp, e.tax_class_id, e.price_type, e.weight_type, e.price_view, e.shipment_type, e.links_purchased_separately, e.links_exist, e.giftcard_amounts, e.allow_open_amount, e.open_amount_min, e.open_amount_max, e.entity_id, e.attribute_set_id, e.type_id, e.allow_open_amount, e.cost, e.created_at, e.email_template, e.enable_googlecheckout, e.giftcard_amounts, e.giftcard_type, e.gift_message_available, e.gift_wrapping_available, e.gift_wrapping_price, e.has_options, e.image_label, e.is_recurring, e.is_redeemable, e.lifetime, e.links_exist, e.links_purchased_separately, e.links_title, e.msrp, e.msrp_display_actual_price_type, e.msrp_enabled, e.name, e.news_from_date, e.news_to_date, e.open_amount_max, e.open_amount_min, e.price, e.price_type, e.price_view, e.recurring_profile, e.required_options, e.shipment_type, e.short_description, e.sku, e.sku_type, e.small_image, e.small_image_label, e.special_from_date, e.special_price, e.special_to_date, e.tax_class_id, e.thumbnail, e.thumbnail_label, e.updated_at, e.url_key, e.url_path, e.use_config_email_template, e.use_config_is_redeemable, e.use_config_lifetime, e.visibility, e.weight, e.weight_type FROM catalog_product_flat_1 AS e INNER JOIN catalog_category_product_index AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(2, 4) AND cat_index.category_id = '2' INNER JOIN catalog_product_index_price AS price_index ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0 WHERE (((((e.news_from_date <= '2015-02-04 23:59:59') OR (e.news_from_date IS null))))) AND (((((e.news_to_date >= '2015-02-04 00:00:00') OR (e.news_to_date IS null))))) AND ((e.news_from_date IS not null) OR (e.news_to_date IS not null))

  • wat you have tried till now can you show ? Feb 4, 2015 at 18:50
  • please show your code.////
    – Amit Bera
    Feb 4, 2015 at 18:51
  • added the method i'm using to get new product collection. Feb 4, 2015 at 18:53
  • try ->addAttributeToSelect('*') before ->addStoreFilter() Feb 4, 2015 at 18:55
  • @PradeepSanku I ran the resultant $collection->getSelect()->__toString() in our sql program and the query doesn't include things like 'brand' or 'product type' which is located in the meta information of the product's admin section. Feb 4, 2015 at 19:02

1 Answer 1


You have 2 options here.

  1. Use ->addAttributeToSelect(array('attr1', 'attr2', ...)). This should make your attributes be loaded in the collection and you have control on what you load.
  2. You can edit the attributes you want in the list and set the flag use in product list to yes. Then rebuild the indexes. This is fast and requires no coding. the downside is the attributes will be loaded in every product list and might impact performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.