14
14
15
15
class RecommendSettings implements ObserverInterface
16
16
{
17
+ const QUANTITY_AND_STOCK_STATUS = 'quantity_and_stock_status ' ;
18
+ const STATUS = 'status ' ;
19
+ const VISIBILITY = 'visibility ' ;
20
+
17
21
/**
18
22
* @var string
19
23
*/
20
- private $ productId = '' ;
24
+ protected $ productId = '' ;
21
25
22
26
/**
23
27
* @param ConfigHelper $configHelper
@@ -27,11 +31,11 @@ class RecommendSettings implements ObserverInterface
27
31
* @param SearchCriteriaBuilder $searchCriteriaBuilder
28
32
*/
29
33
public function __construct (
30
- private readonly ConfigHelper $ configHelper ,
31
- private readonly WriterInterface $ configWriter ,
32
- private readonly ProductRepositoryInterface $ productRepository ,
33
- private readonly RecommendManagementInterface $ recommendManagement ,
34
- private readonly SearchCriteriaBuilder $ searchCriteriaBuilder
34
+ protected readonly ConfigHelper $ configHelper ,
35
+ protected readonly WriterInterface $ configWriter ,
36
+ protected readonly ProductRepositoryInterface $ productRepository ,
37
+ protected readonly RecommendManagementInterface $ recommendManagement ,
38
+ protected readonly SearchCriteriaBuilder $ searchCriteriaBuilder
35
39
){}
36
40
37
41
/**
@@ -119,7 +123,7 @@ protected function validateRelatedProducts(string $changedPath): void
119
123
$ recommendations = $ this ->recommendManagement ->getRelatedProductsRecommendation ($ this ->getProductId ());
120
124
if (empty ($ recommendations ['renderingContent ' ])) {
121
125
throw new LocalizedException (__ (
122
- "It appears that there is no trained model available for the AppID : %1. " ,
126
+ "It appears that there is no trained model available for Algolia application ID : %1. " ,
123
127
$ this ->configHelper ->getApplicationID ()
124
128
));
125
129
}
@@ -141,7 +145,7 @@ protected function validateTrendingItems(string $changedPath): void
141
145
// When no recommendations suggested, most likely trained model is missing
142
146
if (empty ($ recommendations ['renderingContent ' ])) {
143
147
throw new LocalizedException (__ (
144
- "It appears that there is no trained model available for the AppID : %1. " ,
148
+ "It appears that there is no trained model available for Algolia application ID : %1. " ,
145
149
$ this ->configHelper ->getApplicationID ()
146
150
));
147
151
}
@@ -162,7 +166,7 @@ protected function validateLookingSimilar(string $changedPath): void
162
166
$ recommendations = $ this ->recommendManagement ->getLookingSimilarRecommendation ($ this ->getProductId ());
163
167
if (empty ($ recommendations ['renderingContent ' ])) {
164
168
throw new LocalizedException (__ (
165
- "It appears that there is no trained model available for the AppID : %1. " ,
169
+ "It appears that there is no trained model available for Algolia application ID : %1. " ,
166
170
$ this ->configHelper ->getApplicationID ()
167
171
));
168
172
}
@@ -175,13 +179,13 @@ protected function validateLookingSimilar(string $changedPath): void
175
179
/**
176
180
* @return string
177
181
*/
178
- private function getProductId (): string
182
+ protected function getProductId (): string
179
183
{
180
184
if ($ this ->productId === '' ) {
181
185
$ searchCriteria = $ this ->searchCriteriaBuilder
182
- ->addFilter (' status ' , 1 )
183
- ->addFilter (' quantity_and_stock_status ' , 1 )
184
- ->addFilter (' visibility ' , [2 , 3 , 4 ], 'in ' )
186
+ ->addFilter (self :: STATUS , 1 )
187
+ ->addFilter (self :: QUANTITY_AND_STOCK_STATUS , 1 )
188
+ ->addFilter (self :: VISIBILITY , [2 , 3 , 4 ], 'in ' )
185
189
->setPageSize (10 )
186
190
->create ();
187
191
$ result = $ this ->productRepository ->getList ($ searchCriteria );
0 commit comments