0

How to change the name of the product, when adding a product to the cart using observer in Magento 2 I use the following code:

$item->setCustomPrice($specialPrice);
$item->setOriginalCustomPrice($specialPrice);
$item->setName('helllloo');
$item->getProduct()->setIsSuperMode(true);

The price is well updated but not the name. Also, how can i change the text of the success message?

1 Answer 1

0

You must change the product name, not the item . Please try this :

$item->setCustomPrice($specialPrice);
        $item->setOriginalCustomPrice($specialPrice);
        $item->getProduct()->setName('helllloo');
        $item->getProduct()->setIsSuperMode(true);

Your Answer

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

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