Skip to content

Commit d6cb47a

Browse files
authored
Merge pull request #1915 from algolia/release/3.17.3-dev
Release/3.17.3 dev
2 parents c53c12b + 2246523 commit d6cb47a

14 files changed

Lines changed: 123 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# CHANGE LOG
22

3+
## 3.17.3
4+
5+
### Updates
6+
- Fix PHP 8.4 deprecated warning by making $resource parameter explicitly nullable - thank you @mohaelmrabet
7+
8+
### Bug Fixes
9+
- Fixed product url indexing when URL rewrites are disabled
10+
- Defaulted `scopeId` to `0` for config writer call in `InstantSearch::SetSorting` method to prevent integrity constraint violation in integration tests.
11+
312
## 3.17.2
413

514
### Security

Helper/Configuration/InstantSearchHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function setSorting(
128128
self::SORTING_INDICES,
129129
$this->serializer->serialize($sorting),
130130
$scope,
131-
$scopeId
131+
$scopeId ?? 0
132132
);
133133
}
134134

Model/ResourceModel/Job/Grid/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Collection extends JobCollection implements SearchResultInterface
2222
* @param mixed $eventObject
2323
* @param mixed $resourceModel
2424
* @param string $model
25-
* @param null $connection
25+
* @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
2626
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource
2727
*
2828
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -37,7 +37,7 @@ public function __construct(
3737
$eventObject,
3838
$resourceModel,
3939
$model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
40-
$connection = null,
40+
?\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
4141
?\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
4242
) {
4343
parent::__construct(
@@ -91,7 +91,7 @@ public function getSearchCriteria()
9191
}
9292

9393
/**
94-
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
94+
* @param \Magento\Framework\Api\SearchCriteriaInterface|null $searchCriteria
9595
*
9696
* @return $this
9797
*
@@ -121,7 +121,7 @@ public function setTotalCount($totalCount)
121121
}
122122

123123
/**
124-
* @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
124+
* @param \Magento\Framework\Api\ExtensibleDataInterface[]|null $items
125125
*
126126
* @return $this
127127
*

Model/ResourceModel/LandingPage/Grid/Collection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class Collection extends LandingPageCollection implements SearchResultInterface
2121
* @param mixed $eventObject
2222
* @param mixed $resourceModel
2323
* @param string $model
24-
* @param null $connection
25-
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource
24+
* @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
25+
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource
2626
*
2727
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
2828
*/
@@ -36,7 +36,7 @@ public function __construct(
3636
$eventObject,
3737
$resourceModel,
3838
$model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
39-
$connection = null,
39+
?\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
4040
?\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
4141
) {
4242
parent::__construct(
@@ -76,7 +76,7 @@ public function getSearchCriteria()
7676
}
7777

7878
/**
79-
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
79+
* @param \Magento\Framework\Api\SearchCriteriaInterface|null $searchCriteria
8080
*
8181
* @return $this
8282
*
@@ -106,7 +106,7 @@ public function setTotalCount($totalCount)
106106
}
107107

108108
/**
109-
* @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
109+
* @param \Magento\Framework\Api\ExtensibleDataInterface[]|null $items
110110
*
111111
* @return $this
112112
*

Model/ResourceModel/Query/Grid/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Collection extends QueryCollection implements SearchResultInterface
2121
* @param mixed $eventObject
2222
* @param mixed $resourceModel
2323
* @param string $model
24-
* @param null $connection
24+
* @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
2525
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource
2626
*
2727
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -36,7 +36,7 @@ public function __construct(
3636
$eventObject,
3737
$resourceModel,
3838
$model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
39-
$connection = null,
39+
?\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
4040
?\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
4141
) {
4242
parent::__construct(
@@ -76,7 +76,7 @@ public function getSearchCriteria()
7676
}
7777

7878
/**
79-
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
79+
* @param \Magento\Framework\Api\SearchCriteriaInterface|null $searchCriteria
8080
*
8181
* @return $this
8282
*
@@ -106,7 +106,7 @@ public function setTotalCount($totalCount)
106106
}
107107

108108
/**
109-
* @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
109+
* @param \Magento\Framework\Api\ExtensibleDataInterface[]|null $items
110110
*
111111
* @return $this
112112
*

Model/ResourceModel/QueueArchive/Grid/Collection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Collection extends QueueArchiveCollection implements SearchResultInterface
2828
* @param mixed $eventObject
2929
* @param mixed $resourceModel
3030
* @param string $model
31-
* @param null $connection
31+
* @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
3232
* @param AbstractDb|null $resource
3333
*
3434
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -43,7 +43,7 @@ public function __construct(
4343
$eventObject,
4444
$resourceModel,
4545
$model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
46-
$connection = null,
46+
?\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
4747
?AbstractDb $resource = null
4848
) {
4949
parent::__construct(
@@ -113,7 +113,7 @@ public function setTotalCount($totalCount)
113113
}
114114

115115
/**
116-
* @param ExtensibleDataInterface[] $items
116+
* @param ExtensibleDataInterface[]|null $items
117117
*
118118
* @return $this
119119
*

Model/ResourceModel/Run/Grid/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Collection extends RunCollection implements SearchResultInterface
2121
* @param mixed $eventObject
2222
* @param mixed $resourceModel
2323
* @param string $model
24-
* @param null $connection
24+
* @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
2525
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource
2626
*
2727
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -36,7 +36,7 @@ public function __construct(
3636
$eventObject,
3737
$resourceModel,
3838
$model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
39-
$connection = null,
39+
?\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
4040
?\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
4141
) {
4242
parent::__construct(
@@ -76,7 +76,7 @@ public function getSearchCriteria()
7676
}
7777

7878
/**
79-
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
79+
* @param \Magento\Framework\Api\SearchCriteriaInterface|null $searchCriteria
8080
*
8181
* @return $this
8282
*
@@ -106,7 +106,7 @@ public function setTotalCount($totalCount)
106106
}
107107

108108
/**
109-
* @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
109+
* @param \Magento\Framework\Api\ExtensibleDataInterface[]|null $items
110110
*
111111
* @return $this
112112
*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Algolia Search & Discovery extension for Magento 2
22
==================================================
33

4-
![Latest version](https://img.shields.io/badge/latest-3.17.2-green)
4+
![Latest version](https://img.shields.io/badge/latest-3.17.3-green)
55
![Magento 2](https://img.shields.io/badge/Magento-2.4.7+-orange)
66

77
![PHP](https://img.shields.io/badge/PHP-8.2%2C8.3%2C8.4-blue)

Service/Product/RecordBuilder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Magento\Catalog\Api\Data\ProductInterface;
2222
use Magento\Catalog\Model\Product;
2323
use Magento\Catalog\Model\Product\Attribute\Source\Status;
24+
use Magento\Catalog\Model\Product\Url as ProductUrl;
2425
use Magento\Catalog\Model\Product\Visibility;
2526
use Magento\Catalog\Model\ResourceModel\Eav\Attribute as AttributeResource;
2627
use Magento\CatalogInventory\Api\StockRegistryInterface;
@@ -54,6 +55,7 @@ public function __construct(
5455
protected ImageHelper $imageHelper,
5556
protected StockRegistryInterface $stockRegistry,
5657
protected PriceManager $priceManager,
58+
protected ProductUrl $productUrl,
5759
){}
5860

5961
/**
@@ -102,7 +104,7 @@ public function buildRecord(DataObject $entity): array
102104
$customData = [
103105
AlgoliaConnector::ALGOLIA_API_OBJECT_ID => $product->getId(),
104106
'name' => $product->getName(),
105-
'url' => $product->getUrlModel()->getUrl($product, $urlParams),
107+
'url' => $this->productUrl->getUrl($product, $urlParams),
106108
'visibility_search' => (int) (in_array($visibility, $visibleInSearch)),
107109
'visibility_catalog' => (int) (in_array($visibility, $visibleInCatalog)),
108110
'type_id' => $product->getTypeId(),

Test/Integration/Indexing/MultiStoreTestCase.php

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,51 @@ protected function setupStore(StoreInterface $store, bool $enableInstantSearch =
124124
}
125125

126126
/**
127-
* Fetch a category from an index and check its base url
127+
* Fetch an entity from an index and check its base url
128128
*
129+
* @param string $entity
130+
* @param string $entityId
129131
* @param StoreInterface $store
130132
* @param string $baseUrl
131133
* @return void
132-
* @throws NoSuchEntityException
133134
* @throws AlgoliaException
135+
* @throws NoSuchEntityException
134136
*/
135137
protected function validateEntityUrl(string $entity, string $entityId, StoreInterface $store, string $baseUrl): void
138+
{
139+
$hit = $this->getEntityHit($entity, $entityId, $store);
140+
$this->assertStringContainsString($baseUrl, $hit['url']);
141+
}
142+
143+
/**
144+
* @param string $entityId
145+
* @param StoreInterface $store
146+
* @return void
147+
* @throws AlgoliaException
148+
* @throws NoSuchEntityException
149+
*/
150+
protected function validateModelUrl(string $entityId, StoreInterface $store): void
151+
{
152+
$hit = $this->getEntityHit('products', $entityId, $store);
153+
// When area is adminhtml, the url returned by the backend model starts with http://localhost/index.php/backend
154+
// So we need to check if "backend" is not part of the url to assert that the frontend url model is called
155+
$this->assertStringNotContainsString('backend', $hit['url']);
156+
}
157+
158+
/**
159+
* @param string $entity
160+
* @param string $entityId
161+
* @param StoreInterface $store
162+
* @return array
163+
* @throws AlgoliaException
164+
* @throws NoSuchEntityException
165+
*/
166+
protected function getEntityHit(string $entity, string $entityId, StoreInterface $store): array
136167
{
137168
$indexOptions = $this->getIndexOptions($entity, $store->getId());
138169
$results = $this->algoliaConnector->getObjects($indexOptions, [$entityId]);
139-
$hit = reset($results['results']);
140-
$this->assertStringContainsString($baseUrl, $hit['url']);
170+
171+
return reset($results['results']);
141172
}
142173

143174
/**

0 commit comments

Comments
 (0)