Skip to content

Commit

Permalink
Merge branch '2.11.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
rbayet committed Jan 30, 2025
2 parents 7e9a011 + 72e2230 commit beee5d5
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ private function hasPackagesErrors(): bool
private function getPackagesErrors(): array
{
if (null === $this->packagesErrors) {
$this->packagesErrors = [];
if (!empty($this->packagesToCheck)) {
$corePackageVersion = $this->productMetadata->getVersion();
$systemPackages = $this->composerInformationProvider->getComposerInformation()->getSystemPackages();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer versions in the future.
*
* @category Smile
* @package Smile\ElasticsuiteTracker
* @author Richard BAYET <[email protected]>
* @copyright 2025 Smile
* @license Open Software License ("OSL") v. 3.0
*/

namespace Smile\ElasticsuiteTracker\Model\App\Response\Http;

use Magento\Framework\App\PageCache\NotCacheableInterface;
use Magento\Framework\App\Response\Http;

/**
* Custom Http Response object for the elasticsuite/tracker/hit legacy controller.
* Using this object instead of a classic Http response object
* - prevents \Magento\PageCache\Model\App\Response\HttpPlugin from being triggered in the first place
* - and if it was triggered, makes sure that the sendVary method is not called
* - which would result in the loss of the Vary cookie if the user is logged in.
*
* @category Smile
* @package Smile\ElasticsuiteTracker
*/
class TrackerResponse extends Http implements NotCacheableInterface
{
}
2 changes: 1 addition & 1 deletion src/module-elasticsuite-tracker/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<general>
<enabled>1</enabled>
<retention_delay>12</retention_delay>
<use_api>0</use_api>
<use_api>1</use_api>
<is_headless_mode>0</is_headless_mode>
<filter_bot_hits>1</filter_bot_hits>
</general>
Expand Down
12 changes: 12 additions & 0 deletions src/module-elasticsuite-tracker/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@
<type name="Magento\Framework\Session\SessionStartChecker">
<plugin name="elasticsuite_tracker_disable_session" type="Smile\ElasticsuiteTracker\Plugin\SessionStartCheckerPlugin"/>
</type>
<!-- Prevent lack of session start to lead to an empty HttpContext and a removal of the Vary cookie by the FPC in h.png/pixel mode -->
<virtualType name="TrackerResponseContext"
type="Magento\Framework\App\Action\Context">
<arguments>
<argument name="response" xsi:type="object">Smile\ElasticsuiteTracker\Model\App\Response\Http\TrackerResponse</argument>
</arguments>
</virtualType>
<type name="Smile\ElasticsuiteTracker\Controller\Tracker\Hit">
<arguments>
<argument name="context" xsi:type="object">TrackerResponseContext</argument>
</arguments>
</type>

<!-- Example of extending the page map identifier -->
<type name="Smile\ElasticsuiteTracker\Model\Event\Processor\MapPageIdentifier">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ public function afterCreateCollection(ProductsList $subject, $collection)
}
if (!empty($filterQueries)) {
$query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, ['should' => $filterQueries]);

if (substr($condition['operator'], 0, 1) === '!') {
$query = $this->applyNegation($query);
}

$collection->addQueryFilter($query);
}
}
Expand Down Expand Up @@ -205,4 +210,29 @@ private function getCurrentStoreId(ProductsList $subject)

return $storeId;
}

/**
* Instantiate query from type and params.
*
* @param string $queryType Query type.
* @param array $queryParams Query instantiation params.
*
* @return QueryInterface
*/
private function prepareQuery($queryType, $queryParams)
{
return $this->queryFactory->create($queryType, $queryParams);
}

/**
* Apply a negation to the current query.
*
* @param QueryInterface $query Negated query.
*
* @return QueryInterface
*/
private function applyNegation(QueryInterface $query)
{
return $this->prepareQuery(QueryInterface::TYPE_NOT, ['query' => $query]);
}
}

0 comments on commit beee5d5

Please sign in to comment.