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()
->setTime('00:00:00')
->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$todayEndOfDayDate = Mage::app()->getLocale()->date()
->setTime('23:59:59')
->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
/** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
//$collection = Mage::getModel('catalog/product')->getCollection()
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection = $this->_addProductAttributesAndPrices($collection)
->addStoreFilter()
->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')
->addAttributeToFilter(
array(
array('attribute' => 'news_from_date', 'is' => new Zend_Db_Expr('not null')),
array('attribute' => 'news_to_date', 'is' => new Zend_Db_Expr('not null'))
)
)
->setPageSize($this->getProductsCount())
->setCurPage(1);
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
AScat_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) ASminimal_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
FROMcatalog_product_flat_1
ASe
INNER JOINcatalog_category_product_index
AScat_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 JOINcatalog_product_index_price
ASprice_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))