문제

How do I get product ID and product attribute at magento/module-catalog/block/product/view/gallery.php?

Please help, I need to do some image filtering by product custom attribute with the image caption.

thanks

도움이 되었습니까?

해결책

You can use getProduct() function directly in this file because that extends below file which contain this function.

vendor/magento/module-catalog/Block/Product/View/AbstractView.php

You can use below line to get Product ID in that file..

<?php $productId = $this->getProduct()->getId(); ?>

And you can get attribute value using this line

<?php $this->getProduct()->getAttributeText('attribute_code'); ?>

You can replace your attribute code with attribute_code.

Hope this will help you!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top