Magento 2.4.6
I am trying to change the name of a configurable product which is added to the cart. I figured that changing the getProductName
function in \vendor\magento\module-configurable-product\Block\Cart\Item\Renderer\Configurable.php
does the trick.
Now I am trying to override that with a plugin, which does not work. This is what I have:
di.xml
<type name="Magento\ConfigurableProduct\Block\Cart\Item\Renderer">
<plugin name="modify_product_name_cart" type="What\Ever\Plugin\Block\Cart\Item\Renderer\Configurable" sortOrder="3" disabled="false" />
</type>
\app\code\What\Ever\Plugin\Block\Cart\Item\Renderer\Configurable.php
namespace What\Ever\Plugin\Block\Cart\Item\Renderer;
class Configurable {
public function afterGetProductName(\Magento\Quote\Model\Quote\Item $item, $result) {
return __('Product Sample') . ' ' . $item->getProduct()->getName();
}
}
This is not working though, it never reaches the code. So I need to know why the code is not reached and if it was reached, if it is the correct way to change the product name?
Thanks!