Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Problem with attributes
 
Gabriel Queiroz
Member
 
Avatar
Total Posts:  73
Joined:  2008-05-28
Brazil
 

Hi,

Thanks for answering.

Yes, I’m adding it to the home page in CMS. Unfortunatelly, it didn’t work… I’ve changed your code a little, using code instead of attribute, but no luck… here’s the final code…

{{block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml" category_id="4"}} 
{{action method
="addAttribute"}}{{code}}manufacturer{{/code}}{{/action}} 
{{
/block}}

I’ll keep on trying, will post it here if I sort something out…

Thanks!

 Signature 

Gabriel Queiroz Silva

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ross
Sr. Member
 
Avatar
Total Posts:  230
Joined:  2007-08-31
Scarborough, North Yorkshire, UK
 

Hi,
I don’t think it is fully working, I posted my quick fix here:
http://www.magentocommerce.com/boards/viewreply/43954/

 Signature 

Ross Kendall - Web Developer - rosskendall.com
Client Magento websites:
- Out of the Ark Music (UK): a leading publisher of children’s musicals
- Dottie Lottie: children’s clothing boutique

 
Magento Community Magento Community
Magento Community
Magento Community
 
OurWorldTalks
Member
 
Total Posts:  60
Joined:  2008-07-08
 

Hi tzflorida… thanks for the advise on how to show attributes in the category page. For people who can’t get it to work, make sure you insert the code into catalog.xml in both
<catalog_category_default>
and
<catalog_category_layered>
Cheers!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ross
Sr. Member
 
Avatar
Total Posts:  230
Joined:  2007-08-31
Scarborough, North Yorkshire, UK
 

@Victor - did you test your search results page?

 Signature 

Ross Kendall - Web Developer - rosskendall.com
Client Magento websites:
- Out of the Ark Music (UK): a leading publisher of children’s musicals
- Dottie Lottie: children’s clothing boutique

 
Magento Community Magento Community
Magento Community
Magento Community
 
will_h
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2007-09-21
Michigan | USA
 
Moshe - 06 May 2008 10:12 PM

Looks like it was changed. Please try this:

<?php echo $_product->getResource()->getAttribute('my_weight')->getFrontend()->getValue($_product?>

This worked perfectly, added to view.phtml v1.1.1 - Thank you

[EDIT]

This is my final code for displaying my attribute on the product view page. This also makes the text clickable with the URL entered in the attribute field. Also set new classes for the divs.

<?php if ($_product->getResource()->getAttribute('Attribute_Code')->getFrontend()->getValue($_product)):?>
            
<div class="downloads">
                <
div class="head">
                    <
h4>Product Downloads</h4>
                </
div>
                <
a href="<?php echo $_product->getResource()->getAttribute('Attribute_Code')->getFrontend()->getValue($_product) ?>" target="_blank"><?php echo $_product->getResource()->getAttribute('Attribute_Code')->getFrontend()->getLabel($_product?></a>
            </
div>
        
<?php endif;?>

Hope this helps someone in the future.

- Will

 
Magento Community Magento Community
Magento Community
Magento Community
 
InDaMixXx
Member
 
Avatar
Total Posts:  73
Joined:  2008-04-29
 
Moshe - 28 April 2008 10:33 AM

@capple_: if it is a plain text attribute, use:

$_product->getData('part_no')
// or
$_product->getPartNo();
If it is a dropdown, use:
$_product->getAttributeText('part_no')

Hi Moshe & everybody,

I tried all the code to display drop down attributes without any success.

I can display text attributes but not drop-down.

Anyone ? smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
LindyKyaw
Magento Team
 
Total Posts:  31
Joined:  2008-01-02
 

@Gabriiiel

When you tries to print out product in the product list page,

print_r($_product->debug());

Did you see an attribute you would like to use in the print out debug?

If you don’t see the attribute, you need to addAttributeToSelect in the collection object.

 
Magento Community Magento Community
Magento Community
Magento Community
 
InDaMixXx
Member
 
Avatar
Total Posts:  73
Joined:  2008-04-29
 

Hi LindyKyaw…

Thx for your answer…

This piece of code only display “Array"…

So… Something is wrong right ? What is the collection.php file to edit and how to do it ?

Thx by advance,

Gab.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hanneman
Jr. Member
 
Total Posts:  3
Joined:  2007-11-15
Eindhoven, The Netherlands
 

Hi

I have also succeeded in getting a custom text product attribute to show in the product list with:

$_product->getResource()->getAttribute('my_attribute')->getFrontend()->getValue($_product))

But when the attribute is a selectbox the code above only returns the first text option.
What do I need to get the real selected value.

 Signature 

http://www.madia.nl

 
Magento Community Magento Community
Magento Community
Magento Community
 
InDaMixXx
Member
 
Avatar
Total Posts:  73
Joined:  2008-04-29
 

I’d like to know the solution too.

I can’t find anything about this in the phpdocs.

How can we display in the product list a dropdown attribute ? A yes/no attribute ? A text attribute ? Etc for all type of attribute…

Thx by advance LindyKyaw smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hanneman
Jr. Member
 
Total Posts:  3
Joined:  2007-11-15
Eindhoven, The Netherlands
 

The only solution I found for now is hacking in the core:

after (line 64)

$this->_productCollection $layer->getProductCollection();

add
$this->_productCollection->addAttributeToSelect('my_attribute');

In the class Mage_Catalog_Block_Product_List.

I am now looking for a way to get this working from the product/list.phtml template itself.

 Signature 

http://www.madia.nl

 
Magento Community Magento Community
Magento Community
Magento Community
 
InDaMixXx
Member
 
Avatar
Total Posts:  73
Joined:  2008-04-29
 

It works.

I do appreciate your help. Thanks you Hanneman.

I am able to display text attributes, dropdown attributes, date attributes. But what about yes/no attribute ? Just by curiosity smile

By the way… Would u know how to display the search results as products lists ? I mean we could be able to see the same informations in the search products than those of the products list smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hanneman
Jr. Member
 
Total Posts:  3
Joined:  2007-11-15
Eindhoven, The Netherlands
 

Hi,

The yes/no attribute returns when using

$_product->getResource()->getAttribute('my_attribute')->getFrontend()->getValue($_product)
the selected label instead of the selected value ($_product->getMyAttribute() returns the selected value).

Could be an issue when working with different languages....

 Signature 

http://www.madia.nl

 
Magento Community Magento Community
Magento Community
Magento Community
 
InDaMixXx
Member
 
Avatar
Total Posts:  73
Joined:  2008-04-29
 

Hi Hanneman,

Ok… So this is the same code to use than for text attributes..

Concerning label/value… We can solve it in the phtml… With a piece of code… Not a pb smile

So thank you smile

What about the attributes in the list of search results ? How to manage to make it the same than then products list ? smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Aldo
Member
 
Total Posts:  46
Joined:  2008-02-19
 

Hello,

Yes, in the search result, would be great to knwo! wink

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
49897 users|425 users currently online|101900 forum posts