Hi,
I would like to know how to get custom attribute value on a .phtml file, on 1. category page list.phtml and 2. product page view.phtml.
For instance, if I create a dropdown attribute 'mycustomattribute' and the value would be an ID.
I would like to add a php condition such as:
if(myattributevalue == 123): echo "This is 123"; endif;
@Vimal Kumar Thanks for the your answers.
i try to get the data of customer attributes i am not get the data
// log the method print_r(get_class_methods($customer)); $customer = $observer->getEvent()->getCustomer(); echo "Mobile atti". $customer->getCustomAttribute('mobile_att);
try this it will help you.
<?php $_helper = $this->helper('Magento\Catalog\Helper\Output'); $_product = $block->getProduct(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->get('Magento\Framework\Registry')->registry('current_product');//get current product $productTypeInstance = $product->getTypeInstance(); if ($product->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { $usedProducts = $productTypeInstance->getUsedProducts($product); $data = explode(',',$_product->getData('your_attribute')); if(count($data) > 1) { foreach($data as $key => $value): $attr = $_product->getResource()->getAttribute('your_attribute'); if ($attr->usesSource()): $option_value = $attr->getSource()->getOptionText($value); echo $option_value; endif; endforeach; } }