Question

This is my code that imports the images from the server

<?php
 class Bundle_LocalHelpers_Helper_Basic extends Mage_core_Helper_Abstract {

   public function getImageUrl($product)
{

   $storeId = Mage::app()->getStore()->getId();
   $sku = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'sku', $storeId);

    $asin = substr($sku,0,10);

    if ($sku != null) {

        return "http://productimages.shop.com/images/$asin.jpg";
    }
    else
    {
        return "http://productimages.shop.com/images/$sku.jpg";
    }
 }
 }

And from this I am trying to include them in minicart/default.phtml to get the thumbnails however when I try to add the localhelper class the php crashes.

This is the code for the default.phtml

    <?php if ($this->hasProductUrl()): ?>
    <a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><img src="<?php echo $localHelper->getImageUrl($product)->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></a>
<?php else: ?>
    <span class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></span>
<?php endif; ?>

Any suggestions how to add it ?

Was it helpful?

Solution 2

This is the right answer:

 <a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><img src="<?php echo $localHelper->getImageUrl($_item->getProduct());/*echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10');*/ ?>" width="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></a>

Instead of using

$localHelper->getImageUrl($product)

you have to use

$localHelper->getImageUrl($_item->getProduct())

Thank you for trying to help.

OTHER TIPS

Not sure, but I think problem is in resize which you are using. try to remove that. Resize will not work with your third party custom image URL.

<a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><img src="<?php echo $localHelper->getImageUrl($product); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></a>

You can use Mage::helper('localHelpers/basic')->getImageUrl($product) in minicart/default.phtml wherever you want to display the image.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top