0

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

3
  • 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
    Commented Jul 12, 2018 at 12:28
  • no its not my custom attribute i used plugin like this
    – Wahaj Moin
    Commented Jul 12, 2018 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
    Commented Jul 12, 2018 at 12:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.