Magento – Attributes in Item Description / Product Details

You can choose any attributes at any point in the article view of the shop. What you need to?

1. The name / Code to display the Attributes

2. The file, to take over the display

3. A piece of code

 

To 1. sets the attribute to either new or look at the attributes in the backend ( Catalog > Attribute > Manage attributes). There, you look at the notes “Attribut Code”. I want to show the delivery time (MRG does this so, as MRG for Magento 1.6 but not yet goes….) therefore I will remember “delivery_time“.

To 2. The file, The display can be varied by taking: e.g.. app / design / frontend /[base or default]/[IhrTemplate]/template/catalog/product/view.phtml or even a few folders deep (view/type) the default.phtml. I use this file, I would like to have displayed the time of delivery under the already faded Availability. Other files can easily e.g.. about system > Configuration > Developer Tools > Debug > Template Path hints are found.

To 3. The piece of code is (for free-text attributes)

<?php echo $this->__('Name to show') ?> <?php echo $ _product->getHIER denAttributCode() ?>

to me this would be

<?php echo $this->__('Delivery Time:') ?> <?php echo $ _product->getdelivery_time() ?>

Für Dropdown Attribute muss <?php echo $ _product->getdelivery_time() ?> by

<?php echo $ _product->getAttributeText('Attribute code') ?>

be replaced.

For “Ja” / “No” Attributes replace this:

<?php echo $ _product->getAttributCode() ? "Yes" : "No" ?>

The code in the correct place in the install file.

If all three steps are followed, can be seen at the latest after a cache reload out the result.

Picture

It becomes more difficult when multiple selection attributes. By o.g. Unfortunately, the code can be output only attribute value IDs and not names. So here, a clear umständlicherer code used.

In o.g. File can be added at any point following lines:

<?php echo $this->__('Your text BEFORE the attributes') ?>
<?php
$multiSelectArray = $this->getProduct()->getAttributeText('ATTRIBUTE CODE');
$lastItem = end($multiSelectArray);

foreach($multiSelectArray as $multiSelectItem){
echo $multiSelectItem;
if($multiSelectItem != $ LastItem) echo ", ";
}
?>

As always, etc to the correct incorporation of quotes. respect (Copying).

Used in Magento versions 1.5.1.0 and 1.6.1.0. Ask? Comments? Suggestions? Gladly!

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

13 comments on “Magento – Attributes in Item Description / Product Details”

  1. Thanks for the blog post! Very nicely explained. I just wanted to add short, that the getter- (and setter) Methods are written in camel case would, to conform to the Magento Coding Guidelines. Aus getdelivery_time() müsste getDeliveryTime() will. The underscores are removed, and each of the following letter is written in large.
    Alternative, if one does not like this transformation, could also getData(‘delivery_time’) be used.

  2. Can you even enter the code in the list.phtml? Would like attributes in the product overview or. Show in the category overview can not only in the individual products?!

          1. Hi and thanks for the instructions. Klappt super!

            What you have to make because if you have two languages?

            I want e.g.. in German the attribute “Playing time” show. In English, but that is “Playlength” call.

            Would be great if there is a solution to this…

    1. Unfortunately, not. In the backend everything is set up and translated. This is probably due more to the fact that with
      __('To Display Name') ?> getHIER denAttributCode() ?>

      Already the name Yes “set” is. But how do I do it differently so the “Azuzeigender name” is brought up to the respective active StoreView?

  3. Thank you for this guide.

    For a dropdown attribute (delivery_time) I inserted the following code into the view.phtml: __('Delivery:’) ?>getAttributeText(‘delivery_time’) ?>

    Sorry, but I get an error on the product page:

    Delivery time: Fatal error: Call to a member function getSource() on a non-object in /home/deelite/www/batterien-dinkels/app/code/core/Mage/Catalog/Model/Product.php on line 1389

    I use Magento 1.7

    Can anyone help me because maybe?

Leave a Reply

Your email address will not be published. Required fields are marked *