Archive
This post is archived and may contain outdated information. It has been set to 'noindex' and should stop showing up in search results.
Magento 2 M2E Pro Shipping Policy Bug Unknown Modifier H
Jul 19, 2017ProgrammingComments (0)
When attempting to edit or create an eBay Shipping Policy in M2E Pro for Magento 2, you may come across an error like this:

{"error": "Warning: preg_replace(): Unknown modifier 'H' in \/app\/code\/Ess\/M2ePro\/Block\/Adminhtml\/Ebay\/Template\/Shipping\/Edit\/Form\/Data.php on line 1733"}

This happens because the method modifyNonUniqueShippingServicesTitles doesn't properly escape a string before running it through a preg_replace, causing the regular expression to end early. That method is located in this file:

/app/code/Ess/M2ePro/Block/Adminhtml/Ebay/Template/Shipping/Edit/Form/Data.php
The part of the method that is failing is at this line:

$uniqPart = preg_replace('/\w*'.str_replace(' ', '', $title).'/i', '', $ebayId);
To resolve it, add this line of code prior to that code:

// Escapes any '/' in title so preg_replace doesn't fail
$title = str_replace('/', '\/', $title);

It should now look like this:

// Escapes any '/' in title so preg_replace doesn't fail
$title = str_replace('/', '\/', $title);
$uniqPart = preg_replace('/\w*'.str_replace(' ', '', $title).'/i', '', $ebayId);

I have submitted this bug to M2E Pro in hopes they'll fix it in the next update.
Comments (0)
Add a Comment
No comments yet