I want to add value my custom attribute in catagory product page i am using this code "$temp= $subject->getCustomAttribute('option')->getValue();" it give me a value but value is not in my attribute it give me wrong value please help me

  • Is this a custom product attribute? Have you added it to your .xml in your module? Else you have to load the entire product / category .. see: magento.stackexchange.com/questions/110531/… – tecjam Jul 12 '18 at 12:28
  • no its not my custom attribute i used plugin like this – Wahaj Moin Jul 12 '18 at 12:41
  • <?php namespace Wahajmodule\HelloWorld\Model; class Product { public function afterGetName(\Magento\Catalog\Model\Product $subject, $result) { $temp=""; if (null !== $subject->getAttribute('option')) { $temp= $subject->getAttribute('option')->getValue(); } return $result." ".$temp." Kg "; } } – Wahaj Moin Jul 12 '18 at 12:42

Your Answer

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

Browse other questions tagged or ask your own question.