0

I have a sidebar whislist /app/design/frontend/base/default/template/wishlist/sidebar.phtml I need to add a "custom attribute" called manufacturer.

I have tried many options like these but all don't show a thing:

<?php echo $this->getManufacturer()) ?>

<?php echo $this->htmlEscape($_item->getData('manufacturer')); ?>
<?php echo $_product->getManufacturer() ?>

<?php $_item = $this->getItem()?>
<?php $_product= Mage::getSingleton('catalog/product')->load($_item->getProductId()) ?>
<?php echo $_product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($_product); ?>

<?php echo $item->getAttributeText('manufacturer') ?> 
<?php echo $item->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($item); ?>

Thisone shows "3" and no manufacturer name, at least showing something..

<?php echo $this->htmlEscape($_item->getManufacturer()) ?>

How can I get my manufacturer there? I can show them about everywhere else..

2 Answers 2

0

Look at the loop code of sidebar, by default it's:

<?php foreach ($this->getWishlistItems() as $_item): ?>

Inside thip loop $_item->getManufacturer() will return your attribute value, but you have to be sure, that product have this attribute fulfilled.

You can display it i.e. like this:

<?php if ( $_item->getManufacturer() ): ?>
Manufacturer: <?php echo $this->htmlEscape($_item->getManufacturer()) ?>
<?php endif ?>

Edit:

Which Magento version you're using? Probably this code will work, but its not optimal:

<?php if ( $manufacturer = Mage::getModel('catalog/product')->load($_item->getId())->getAttributeText('manufacturer') ): ?>
    Manufacturer: <?php echo $this->htmlEscape( $manufacturer ) ?>
<?php endif ?>
2
  • This shows the 3 while it should display a manufacturer. (backend I made a dropdown of the manufacturers)
    – magmarc
    Commented Jul 10, 2013 at 8:16
  • Which Magento version you're using? Probably this code will work, but its not optimal: <?php if ( $manufacturer = Mage::getModel('catalog/product')->load($_item->getId())->getAttributeText('manufacturer') ): ?> Manufacturer: <?php echo $this->htmlEscape( $manufacturer ) ?> <?php endif ?> Commented Jul 10, 2013 at 8:46
0

The reason this isn't working:

<?php echo $item->getAttributeText('manufacturer') ?> 

Is likely because manufacturer isn't in the $item's parent collection.

You need to extend the method that gets the collection and add the manufacturer attribute from Mage_Wishlist_Model_Resource_Item_Collection:

/**
 * Retrieve Wishlist Product Items collection
 *
 * @return Mage_Wishlist_Model_Resource_Item_Collection
 */
public function getWishlistItems()
{
    if (is_null($this->_collection)) {
        $this->_collection = clone $this->_createWishlistItemCollection();
        $this->_collection->clear();
        $this->_prepareCollection($this->_collection);
    }
    $this->_collection->addAttributeToSelect('manufacturer');
    return $this->_collection;
}
1
  • I have add the code to /app/code/core/Mage/Wishlist/Model/Mysql4/Wishlist/Collection.php - It didn't work. I have add the code to /app/code/core/Mage/Wishlist/Model/Mysql4/Item/Collection.php - Also didn't work.
    – magmarc
    Commented Jul 10, 2013 at 8:30

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.