Invalid Magento image attribute. How do I get into the frontman?

I added an image attribute with a name and label, for example. New image, new_image.

How to get this from e.g. view.phtml? I thought it would be as simple as

<?php
    echo $this->helper('catalog/image')->init($_product, 'new_image')->resize(150, 150);
?>

But it causes an error.

Does anyone know the right way to do this?

Many thanks.

+3
source share
6 answers

Shonkton, I can verify that your code worked fine in the /product/view.phtml directory. I believe that you added an image attribute to the attribute group ... Note that echo output will provide a link to the image, so it should be enclosed in an image tag.

    echo $this->helper('catalog/image')->init($_product, 'new_image')->resize(150, 150);
+1
source

, , , , . , , . :

$product=Mage::getModel('catalog/product')->load($_product->getId());

$product $_product ,

helper('catalog/image')->init($product, 'new_image')->resize(150, 150); ?>

.

, , . , -, .

+3

, . .

, - , .

$isNewImage =$_product->getResource()->getAttribute('new_image')->getFrontend()->getValue($_product);

,

<?php if ( $isNewImage != 'no_selection'):?>

$_newImg ='<img id="your-id" src="'.$this->helper('catalog/image')->init($_product, 'new_image')->resize(300,300).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';

 echo $_helper->productAttribute($_product, $_newImg , 'new_image'); 

<?php  endif; ?>
+3

- : images/catalog/product/placeholder/custom_image.jpg

+3

init: image, small_image thumbnail, . , new_image .

"" , , .

,

0

Farrukhs ,

, $_helper, , , $_newImg

Secondly, I show my image in a jquery scriptoluscious popup window, and this code forces this window to open the site itself in a popup window, and at level 3 it displays my image attribute ... It almost feels like the beginning of the movie when you keep clicking the popup in the popup frame until you get the image ... Just wanted to share information about Bizz!

0
source

Source: https://habr.com/ru/post/1753870/


All Articles