0

I'm developing a new order conformation page in magento 1.9.3 and I have everything working yet I can't seem to get the image from this here,

'imgUrl' => Mage::getModel('catalog/product_media_config')->getMediaUrl( $_product->getThumbnail()),

what I get as a result is,

< img src="https://mycompany.com/media/catalog/product/" alt="product title works">

I can't seem to get this straight, can anyone help me understand why this isn't working.

my full code is everything else works fine but I can't seem to get the full path of the image correctly

$_order = $this->getOrder();

if ($_order){
$wa_data = array(
'symbol' => Mage::app()->getLocale()->currency(Mage::app()->getStore()
  ->getCurrentCurrencyCode())->getSymbol(),
 'items' => $_order->getAllItems(),

);

foreach ($wa_data['items'] as $key => $value) {
$vars = get_object_vars ($value);
$_product = Mage::getModel('catalog/product')
->setStoreId($value->getOrder()->getStoreId())
->load($value->getProductId());
$item = array(
'url' => $_product->getProductUrl(),
'imgUrl' => Mage::getModel('catalog/product_media_config')->getMediaUrl( 
$_product->getThumbnail()),
'name' => $value->getName(),
'sku' => $vars['_data']['sku'],
'description' => $vars['_data']['description'],
'number' => $vars ['_data']['product_id'],
'qty' => intval($vars['_data']['qty_ordered']),
'price' => $wa_data['symbol'] . ' ' . intval($vars['_data']['base_price']),
'total' => $wa_data['symbol'] . ' ' . intval($vars['_data']
['base_row_total']),
);
$wa_data['items'][$key] = $item;
}

}else{
$wa_data = array(
'symbol' => Mage::app()->getLocale()->currency(Mage::app()->getStore()
  ->getCurrentCurrencyCode())->getSymbol(),
);
for($i=0; $i < 5; $i++) {
$item = array(
'url' => '#',
'imgUrl' => 'https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png',
'name' => 'Product' . $i,
'sku' => "SKU {$i}",
'description' => "Description {$i} Maecenas faucibus mollis interdum. Nulla 
vitae elit libero, a pharetra augue. Fusce dapibus, tellus ac cursus commodo",
'number' => "123456number{$i}",
'price' => ($i+1) * 49,
'qty' => $i+1,
'total' => $wa_data['symbol'] . ' ' . (($i+1) * ($i+1) * 49),
);
$wa_data['items'][$i] = $item;
}
}; ?>
  • hi let's try like this echo Mage::helper('catalog/image')->init($_product, 'small_image')->resize(50,50); – Nagaraju K Jul 27 '17 at 3:53
  • 1
    I get the /placeholder/small_image.jpg placeholder image. it's working but I need to trouble shoot why only the place holder image is showing up. – gx2g Jul 27 '17 at 7:45
0

after much review I was able to get this working by simply using,

 Mage::getSingleton('catalog/product_media_config')->getMediaUrl($_product->getThumbnail()),

getSingleton instead of getModel and it worked perfect, both the url and thumbnail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.