How to exclude Amazon / Ebay / other marketplaces orders in your Audience tool

Audience is a great tool but you need to feed it with a clear set of sales data in order to make it produce reliable estimations about newsletter marketing and remarketing / retargeting campaigns ROIs.

Why do you need that?

Out-of-the-box Audience crunches all the sales data coming from your PrestaShop database. Your clients' email addresses will be then synced with your newsletter and/or your ads platform in order to contact those clients for remarketing purposes.

The problem is that when someone places and order from a third-party marketplace like Ebay or Amazon, the client's email address is replaced with a fake one, looking like


and such email addresses are clearly not real and useless in terms of direct marketing and retargeting campaigns.

So, if you use your PrestaShop ecommerce as endpoint for marketplaces like Ebay and Amazon, you need to make sure to sync with the control panel only orders coming from your website.

How can you achieve that result? 

You can modify in our module folder the following file:

/ controllers / front / order.php

structuring the original sync query - the one that fetches orders - as follows:

$sql = "SELECT *, (
FROM "._DB_PREFIX_."order_state_lang osl
WHERE osl.id_order_state = o.current_state
AND osl.id_lang = ".(int)$this->getLanguageId()."
) AS state_name, o.date_add AS date_add, o.date_upd AS date_upd
FROM "._DB_PREFIX_."orders o
LEFT JOIN "._DB_PREFIX_."customer c ON (c.id_customer = o.id_customer)
WHERE o.module not in ('amazon', 'fastbay1', 'ibssync', 'feedbiz', 'cdiscount')
".Shop::addSqlRestriction(false, 'o')."
ORDER BY o.date_add DESC
".($limit != '' ? $limit : '');

then you can replace "amazon", "fastbay1" with the domain names of the modules that you use to receive orders from other marketplaces.

IMPORTANT: you need to do that change before running the first sync of your store. The first sync is what initialises every store AI and, if you sync fake email addresses like the ones above, you will not be able to remove them unless you  clone your existing store and run a new, fresh, first sync.