Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento2: Add product attribute as Media Image

I had an issue when we add a product attribute as a Media Image type. I created the attribute successfully through the backend.

But it is not displaying in the Add Product page in the back end. I selected the corresponding attribute in Add Attribute area also.

like image 730
VIPIN A ROY Avatar asked Dec 04 '15 06:12

VIPIN A ROY


2 Answers

Finally, I got the proper way to solve this problem. We can add media images through the section "Images and Videos". After uploading the image, just click on that image and specify it as an attribute image.

like image 103
VIPIN A ROY Avatar answered Jan 02 '23 04:01

VIPIN A ROY


Currently there is a bug with custom Media Attributes. You can read about this on forum. I resolve this by entering Browser Inspector and display proper tab (Storefront Properties) in Magento 2 Admin Panel (just remove display:none style), to set "Used in Product Listing" to Yes. Then you can use this in .phtml file by code:

$product->getCustomAttribute( 'attribute_code' );
like image 29
Jan Żaba Avatar answered Jan 02 '23 04:01

Jan Żaba