1212use Magento \Catalog \Model \ProductCategoryList ;
1313use Magento \Catalog \Model \ResourceModel \Product \Collection ;
1414use Magento \Framework \DB \Select ;
15+ use Magento \Framework \Exception \LocalizedException ;
1516use Magento \Store \Model \Store ;
17+ use Zend_Db_Select_Exception ;
1618
1719/**
1820 * Rule product condition data model
@@ -201,34 +203,6 @@ protected function addNotGlobalAttribute(
201203 \Magento \Catalog \Model \ResourceModel \Eav \Attribute $ attribute ,
202204 Collection $ collection
203205 ) {
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-
232206 $ connection = $ this ->_productResource ->getConnection ();
233207 switch ($ attribute ->getBackendType ()) {
234208 case 'decimal ' :
@@ -244,8 +218,14 @@ protected function addNotGlobalAttribute(
244218 $ aliasDefault = 'at_ ' . sha1 ($ this ->getId ()) . $ attribute ->getAttributeCode () . '_default ' ;
245219 $ aliasStore = 'at_ ' . sha1 ($ this ->getId ()) . $ attribute ->getAttributeCode ();
246220
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+ );
249229 $ linkField = $ attribute ->getEntity ()->getLinkField ();
250230
251231 $ collection ->getSelect ()->joinLeft (
@@ -263,8 +243,8 @@ protected function addNotGlobalAttribute(
263243 }
264244
265245 $ 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 ' ])
268248 ) {
269249 $ conditionCheck = $ connection ->quoteIdentifier ($ aliasStore . '.value_id ' ) . " > 0 " ;
270250 $ conditionTrue = $ connection ->quoteIdentifier ($ aliasStore . '.value ' );
0 commit comments