Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Add Attribute to Product list
 
Alekc
Jr. Member
 
Total Posts:  20
Joined:  2008-05-29
 

Hi, since new versions of Magento i have some problems in adding extra attributes to product listing (in particular news_from_date and news_to_date).

I’ve tried to alter catalog\model\layer.php -> prepareProductCollection() in this way (for testing):

$collection
            
->addAttributeToSelect("*")
            ->
addMinimalPrice()
            ->
addFinalPrice()
            ->
addTaxPercents()
            ->
addStoreFilter();
In debug i can see that $_productCollection->_selectAttributes (in list.phtml) has 55 Elements:
weight_type
weight
visibility
url_path
url_key
updated_at
type_id
tier_price
thumbnail
tax_class_id
status
special_to_date
special_price
special_from_date
small_image
sku_type
sku
short_description
shipment_type
required_options
prossimi_arrivi
price_view
price_type
price
piu_venduti
options_container
old_id
novita
news_to_date
news_from_date
name
minimal_price
meta_title
meta_keyword
meta_description
media_gallery
manufacturer
image
has_options
gift_message_available
genere
gallery
featured
entity_type_id
entity_id
description
custom_layout_update
custom_design_to
custom_design_from
custom_design
created_at
cost
color
category_ids
attribute_set_id

But when it’s stripped to single product with foreach cycle, $_product->_data contains only 42 Elements

weight
website_id
visibility
url_path
url_key
updated_at
type_id
thumbnail
tax_percent
tax_class_id
stock_item
status
special_price
special_from_date
small_image
sku
short_description
request_path
price
position
options_container
name
minimal_tax_class_id
minimal_price
meta_title
meta_keyword
meta_description
is_salable
image
has_options
gift_message_available
entity_type_id
entity_id
description
custom_layout_update
custom_design
created_at
cost
category_ids
calculated_final_price
attribute_set_id
_rule_price

And it’s missing news_from_date and news_to_date :S

Any suggestions?

Thx in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
brendanb
Mentor
 
Total Posts:  1093
Joined:  2008-07-16
London, United Kingdom
 

hey aleck

check this thread out.

im not sure its exactly what ur after, but if you want to add for example the attribute color to the product.list phtml have a read through the posts.

http://www.magentocommerce.com/boards/viewthread/16942/

let me know how you go

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
Alekc
Jr. Member
 
Total Posts:  20
Joined:  2008-05-29
 

nvm, my bad. It turned out that first items haven’t had this attributes setted, that’s why i was not able to see result of edits in debug....

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top