0

we are using magento 2.1.9ce

In the transactional sales e-mails is the sku shown. I have found that the vendor/magento/module-sales/Block/Order/Email/Items/Order/DefaultOrder.php controls this sku.

Now I would like to add in the same line a custom attribute. So we get: SKU: defaultSKU / customSKU

Now I have tried for testing to replace the default SKU with the custom attribute like this:

return $item->getAttribute('artikelnummer');

But in my sales e-mail the SKU line stays empty. The attribute name of the custom SKU is artikelnummer

How can I do this?

1

try below code:

Vendor/Email/Block/Order/Email/Items/DefaultItems.php

$item->getProduct()->getAttributeText('artikelnummer');

It will return your custom attribute value of a particular product.

Thanks

  • I tried this But the result in the email remains blank – Ronny Jul 10 '18 at 18:51
  • try that code in here <Vendor>/Email/Block/Order/Email/Items/DefaultItems.php – Abhishek Panchal Jul 10 '18 at 18:55
  • also tried this without result. it remains empty. And the product does have a value in the attribute artikelnummer. so that cannot be the problem – Ronny Jul 10 '18 at 19:00
  • can you please add your code.. how you are trying? – Abhishek Panchal Jul 10 '18 at 19:01
  • public function getSku($item) { if ($item->getProductOptionByCode('simple_sku')) { /**return $item->getProductOptionByCode('simple_sku');*/ return $item->getProduct()->getAttributeText('artikelnummer'); } else { return $item->getSku(); } } – Ronny Jul 10 '18 at 19:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.