Skip to content

Commit 782d342

Browse files
committed
AC-1214:Price mismatch in frontend product search and product details pages
- Removed overriden function and modified query to fecth price scope specific data
1 parent e60bc4b commit 782d342

File tree

1 file changed

+12
-61
lines changed

1 file changed

+12
-61
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Collection/AbstractCollection.php

Lines changed: 12 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,18 @@ protected function _getLoadAttributesSelect($table, $attributeIds = [])
158158
$entityIdField = $indexList[$connection->getPrimaryKeyName($entityTable)]['COLUMNS_LIST'][0];
159159

160160
if ($storeId) {
161+
162+
foreach ($attributeIds as $id) {
163+
$attribute = $this->_eavConfig->getAttribute(
164+
$this->getEntity()->getType(),
165+
$id
166+
);
167+
168+
if ($attribute->getAttributeCode() === 'price' && (int)$attribute->getIsGlobal() === 1) {
169+
$storeId = $this->getDefaultStoreId();
170+
}
171+
}
172+
161173
$joinCondition = [
162174
't_s.attribute_id = t_d.attribute_id',
163175
"t_s.{$entityIdField} = t_d.{$entityIdField}",
@@ -230,67 +242,6 @@ protected function _addLoadAttributesSelectValues($select, $table, $type)
230242
return $select;
231243
}
232244

233-
/**
234-
* Initialize entity object property value
235-
*
236-
* Update attribute value if attribute scope is global
237-
*
238-
* Parameter $valueInfo is _getLoadAttributesSelect fetch result row
239-
*
240-
* @param array $valueInfo
241-
* @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
242-
* @throws LocalizedException
243-
*/
244-
protected function _setItemAttributeValue($valueInfo)
245-
{
246-
$entityIdField = $this->getEntity()->getEntityIdField();
247-
$entityId = $valueInfo[$entityIdField];
248-
if (!isset($this->_itemsById[$entityId])) {
249-
throw new LocalizedException(
250-
__('A header row is missing for an attribute. Verify the header row and try again.')
251-
);
252-
}
253-
254-
$attribute = $this->_eavConfig->getAttribute(
255-
$this->getEntity()->getType(),
256-
$valueInfo['attribute_id']
257-
);
258-
if ((int)$attribute->getIsGlobal() === ScopedAttributeInterface::SCOPE_GLOBAL) {
259-
$select = $this->getConnection()->select()
260-
->from(
261-
['e' => $this->getEntity()->getEntityTable()],
262-
['entity_id']
263-
)
264-
->join(
265-
['t_d' => $attribute->getBackend()->getTable()],
266-
"e.{$this->getEntity()->getLinkField()} = t_d.{$attribute->getEntity()->getLinkField()}",
267-
['t_d.value']
268-
)->where(
269-
" e.entity_id = ?",
270-
$entityId,
271-
\Zend_Db::INT_TYPE
272-
)->where(
273-
't_d.attribute_id = ?',
274-
$attribute->getAttributeId(),
275-
\Zend_Db::INT_TYPE
276-
)->where(
277-
't_d.store_id = ?',
278-
$this->getDefaultStoreId(),
279-
\Zend_Db::INT_TYPE
280-
);
281-
$data = $this->getConnection()->fetchRow($select);
282-
if ($data && is_array($data)) {
283-
$valueInfo['value'] = $data['value'];
284-
}
285-
}
286-
287-
foreach ($this->_itemsById[$entityId] as $object) {
288-
$object->setData($attribute->getAttributeCode(), $valueInfo['value']);
289-
}
290-
291-
return $this;
292-
}
293-
294245
/**
295246
* Adding join statement to collection select instance
296247
*

0 commit comments

Comments
 (0)