12
12
use Magento \Catalog \Model \ProductCategoryList ;
13
13
use Magento \Catalog \Model \ResourceModel \Product \Collection ;
14
14
use Magento \Framework \DB \Select ;
15
+ use Magento \Framework \Exception \LocalizedException ;
15
16
use Magento \Store \Model \Store ;
17
+ use Zend_Db_Select_Exception ;
16
18
17
19
/**
18
20
* Rule product condition data model
@@ -201,34 +203,6 @@ protected function addNotGlobalAttribute(
201
203
\Magento \Catalog \Model \ResourceModel \Eav \Attribute $ attribute ,
202
204
Collection $ collection
203
205
) {
204
- /*$storeId = $this->storeManager->getStore()->getId();
205
- $values = $collection->getAllAttributeValues($attribute);
206
- $validEntities = [];
207
- if ($values) {
208
- foreach ($values as $entityId => $storeValues) {
209
- if (isset($storeValues[$storeId])) {
210
- if ($this->validateAttribute($storeValues[$storeId])) {
211
- $validEntities[] = $entityId;
212
- }
213
- } else {
214
- if (isset($storeValues[Store::DEFAULT_STORE_ID]) &&
215
- $this->validateAttribute($storeValues[Store::DEFAULT_STORE_ID])
216
- ) {
217
- $validEntities[] = $entityId;
218
- }
219
- }
220
- }
221
- }
222
- $this->setOperator('()');
223
- $this->unsetData('value_parsed');
224
- if ($validEntities) {
225
- $this->setData('value', implode(',', $validEntities));
226
- } else {
227
- $this->unsetData('value');
228
- }
229
-
230
- return $this;*/
231
-
232
206
$ connection = $ this ->_productResource ->getConnection ();
233
207
switch ($ attribute ->getBackendType ()) {
234
208
case 'decimal ' :
@@ -244,8 +218,14 @@ protected function addNotGlobalAttribute(
244
218
$ aliasDefault = 'at_ ' . sha1 ($ this ->getId ()) . $ attribute ->getAttributeCode () . '_default ' ;
245
219
$ aliasStore = 'at_ ' . sha1 ($ this ->getId ()) . $ attribute ->getAttributeCode ();
246
220
247
- $ storeDefaultId = $ connection ->getIfNullSql ($ aliasDefault . '.store_id ' , Store::DEFAULT_STORE_ID );
248
- $ storeId = $ connection ->getIfNullSql ($ aliasStore . '.store_id ' , $ this ->storeManager ->getStore ()->getId ());
221
+ $ storeDefaultId = $ connection ->getIfNullSql (
222
+ $ aliasDefault . '.store_id ' ,
223
+ Store::DEFAULT_STORE_ID
224
+ );
225
+ $ storeId = $ connection ->getIfNullSql (
226
+ $ aliasStore . '.store_id ' ,
227
+ $ this ->storeManager ->getStore ()->getId ()
228
+ );
249
229
$ linkField = $ attribute ->getEntity ()->getLinkField ();
250
230
251
231
$ collection ->getSelect ()->joinLeft (
@@ -263,8 +243,8 @@ protected function addNotGlobalAttribute(
263
243
}
264
244
265
245
$ fromPart = $ collection ->getSelect ()->getPart (Select::FROM );
266
- if (isset ($ fromPart [' search_result ' ]['joinType ' ])
267
- && $ fromPart [' search_result ' ]['joinType ' ] == Select:: LEFT_JOIN
246
+ if (isset ($ fromPart [$ aliasStore ]['joinType ' ])
247
+ && isset ( $ fromPart [$ aliasDefault ]['joinType ' ])
268
248
) {
269
249
$ conditionCheck = $ connection ->quoteIdentifier ($ aliasStore . '.value_id ' ) . " > 0 " ;
270
250
$ conditionTrue = $ connection ->quoteIdentifier ($ aliasStore . '.value ' );
0 commit comments