Set product title as unique
First, you'll need to set the product title as unique. This way, Feeds will only import one product per title.
Is the "=" at the end important to the product title? If not, you'll need to find a way to remove that sign from the product title. This way, Feeds will treat a product title with an "=" as equal to the same product title without the "=".
Find replace Tamper plugin (D7 and D8)
If you are certain that the sign "=" is only used at the end of the product title (or meaningless if it appears anywhere else), you can use the easiest solution: Use the Tamper plugin "Find replace" to replace "=" with "". This plugin is available for both D7 and D8.
Find replace REGEX Tamper plugin (currently D7 only)
If the "=" sign can appear elsewhere in the product title and is important there, you'll need to use the "Find replace REGEX" tamper plugin. In the field "REGEX to find", enter a regex that matches strings ending with a "=":
/\=$/
And replace with an empty string.
D7 or D8?
At the moment of writing, the Tamper plugin "Find replace REGEX" has not been ported to D8 yet (see https://www.drupal.org/project/tamper/issues/2975179 for the status). If you are using D8 and the Tamper plugin "Find replace" does not suffice, you'll to create a custom module and listen to the Feeds parse event in order to apply modifications on the product titles.
Example:
namespace Drupal\mymodule\EventSubscriber;
class ProductFeedSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[FeedsEvents::PARSE][] = ['afterParse', FeedsEvents::AFTER];
return $events;
}
/**
* Act on parser result.
*/
public function afterParse(ParseEvent $event) {
// Check if this is the feed we want to edit.
$feed_type_id = $event->getFeed()->getType()->id();
if ($feed_type_id != 'myfeedtype') {
// Not the feed type we want to edit. Abort.
return;
}
/** @var \Drupal\feeds\Result\ParserResultInterface */
$parser_result = $event->getParserResult();
/** @var \Drupal\feeds\Feeds\Item\ItemInterface */
foreach ($parser_result as $item) {
// Get product title.
$title = $item->get('title');
// Remove "=" sign from the end if there is any.
$title = preg_replace('/\=$', '', $title);
// Set title back on item.
$item->set('title', $title);
}
}
}
Be sure to replace "myfeedtype" in the example above with the name of the feed type that you created for importing products.
An event listener always needs to be declared in your module's 'services.yml' file:
services:
mymodule.product_feed:
class: Drupal\mymodule\EventSubscriber\ProductFeedSubscriber
tags:
- {name: event_subscriber}
In the D7 version, you would need to implement the hook hook_feeds_after_parse()
to alter the parsed result.