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:


<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" />


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?


  • I think you do not seen the changes to miniCart pop/dropdown?
    – Amit Bera
    Jun 6 at 9:44
  • is change related to JavaScript you need to override minicart.js
    – Jay Parmar
    Jun 6 at 9:55
  • When I add the changes to Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable.php directly, it works and I see the changes in the mini cart. To make it the propber way, I wanted to create a plugin, which does not work though. I think no JS has to be involved here... Jun 6 at 12:17
  • Did you ever figure this out? It would be useful for something I'm working on. Sep 27 at 12:07


Your Answer

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

Browse other questions tagged or ask your own question.