Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[B2B] Add the company_id and customer_group_id in the tracking data #3340

Open
romainruaud opened this issue Aug 2, 2024 · 0 comments
Open
Assignees
Labels

Comments

@romainruaud
Copy link
Collaborator

Step 1.

When using the Magento B2B modules and browsing the front-office as a logged-in customer belonging to a particular company_id, add this data to the data being sent by the tracker to the backend.

Add the field here : https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-tracker/etc/elasticsuite_indices.xml#L30
And here : https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-tracker/etc/elasticsuite_indices.xml#L122

Do the same for the customer_group_id.

Step 2.

Then in the Search Analytics screen :

  • append a Customer group selector in the top of the page. Selecting a customer should refresh the tracking data and display only data for this customer group.

  • if the B2B module is enabled, append a Company selector in the top of the page. Same, selecting a company should refresh the tracking data and display only data for this company.

Then, you'll need to add these data into the Report context : https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-analytics/Model/Report/Context.php

And for the reports to work, you'll have to implement two classes for each company_id/customer_group_id :

Smile\ElasticsuiteAnalytics\Model\Report\Event\CustomerGroupIdFilterQueryProvider
Smile\ElasticsuiteAnalytics\Model\Report\Event\CompanyIdQueryFilterProvider

Smile\ElasticsuiteAnalytics\Model\Report\Session\CustomerGroupIdFilterQueryProvider
Smile\ElasticsuiteAnalytics\Model\Report\Session\CompanyIdQueryFilterProvider

And inject them via the DI to the proper reports : https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-analytics/etc/di.xml

The implementation of these classes should be inspired from the DateFilterQueryProvider. Most probably, to filter on customer_group_id and company_id, a TERM query should be sufficient.

Something like :

$companyId = $this->context->getCompanyId();
if ($companyId) {
    $query = $this->queryFactory->create(QueryInterface::TYPE_TERM, ['value' => $companyId]);
}
vahonc added a commit to vahonc/elasticsuite that referenced this issue Sep 20, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Sep 20, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Sep 20, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Sep 30, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Sep 30, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Sep 30, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Oct 10, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Oct 10, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Oct 10, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Oct 10, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Oct 10, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Oct 28, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Oct 28, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Oct 29, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Nov 28, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Nov 28, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Nov 29, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Nov 29, 2024
vahonc added a commit to vahonc/elasticsuite that referenced this issue Nov 29, 2024
rbayet pushed a commit that referenced this issue Dec 2, 2024
rbayet pushed a commit that referenced this issue Dec 2, 2024
rbayet pushed a commit that referenced this issue Dec 2, 2024
rbayet pushed a commit that referenced this issue Dec 2, 2024
rbayet added a commit that referenced this issue Dec 2, 2024
…analytics-tracker-add-company_id-and-customer_group_id-in-tracking-data

[Analytics][Tracker] Feature #3340, add company_id and customer_group_id in tracking data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants