I need to change the productname visible for the customer after adding it to the cart. Also it should show on invoice, order email and everything else visible for the customer.
I made an extension with observer checkout_cart_product_add_after
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item->getProduct()->setName('this is the productname');
$item->getProduct()->setIsSuperMode(true);
But the original productname is still visible on minicart, cartpage, etc.
The ‘add to cart message’ is the only place where the new changed productname is visible. What should I change?
2
Answers
Found the solutions myself.
Hope this helps anyone searching for it, or if you have comments how it could be done a better way, please let me know.
Created a plugin with this code:
So this sets a new name to the quote item, visible in everything, excepting cart and mini cart.
Now I have got my new productname visible in: - Added to cart message - Quote-item, even in admin and invoices
But not in: - Mini cart - Cartpage
For the cart page:
I changed output of function getProduct in MagentoCheckoutBlockCartItemRenderer:
For minicart, also with plugin:
use this event "sales_quote_item_set_product"
and in observer set name like this: