I'm need to remove the quote marks from the product name because it is messing up the Data Layer.

$product['name'] = $item->getName();

How can I do it in the above code? Thanks

  • Does that mean your product names are like this 'name' ? Apr 27, 2017 at 19:05
  • No some my product names have quote marks in them, for example, Natures Grace "Grace" Figurine. And I get errors: Uncaught SyntaxError: Unexpected identifier
    – Freejoy
    Apr 27, 2017 at 19:11

1 Answer 1


Try this

$product['name'] = str_replace('"', '', $item->getName()); // This will remove all double quotes from product name.
  • How could I add that to the above code? It seems I remember Magento having some kind of code for this. Not sure.
    – Freejoy
    Apr 27, 2017 at 19:17
  • Updated the code. Check now. Apr 27, 2017 at 19:22
  • If the answer helps kindly try to accept it. Apr 27, 2017 at 19:34
  • I think it will work, but I might have the wrong place targeted. : ) Be back
    – Freejoy
    Apr 27, 2017 at 19:38

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.

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