Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle when attr. store scope value exist without a value for the default scope #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -454,20 +454,36 @@ protected function _getAttributes($storeId, array $entityIds, array $attributeTy
foreach ($attributeTypes as $tableName => $attributeIds) {
if ($attributeIds) {
$select = $adapter->select()
->from(array('t_default' => $tableName), array('entity_id', 'attribute_id'))
->from(array('t_main' => $tableName), array(
'entity_id',
'attribute_id',
'value' => new Zend_Db_Expr('COALESCE(t_store.value, t_default.value)')
))
->joinLeft(
array('t_default' => $tableName),
$adapter->quoteInto(
't_main.entity_id=t_default.entity_id' .
' AND t_main.attribute_id=t_default.attribute_id' .
' AND t_default.store_id=?',
0
),
array()
)
->joinLeft(
array('t_store' => $tableName),
$adapter->quoteInto(
't_default.entity_id=t_store.entity_id' .
' AND t_default.attribute_id=t_store.attribute_id' .
't_main.entity_id=t_store.entity_id' .
' AND t_main.attribute_id=t_store.attribute_id' .
' AND t_store.store_id=?',
$storeId
),
array('value' => new Zend_Db_Expr('COALESCE(t_store.value, t_default.value)'))
array()
)
->where('t_default.store_id=?', 0)
->where('t_default.attribute_id IN (?)', $attributeIds)
->where('t_default.entity_id IN (?)', $entityIds);
->where('t_main.store_id IN (?)', array(0, $storeId))
->where('t_main.attribute_id IN (?)', $attributeIds)
->where('t_main.entity_id IN (?)', $entityIds)
->group(array('t_main.attribute_id', 't_main.entity_id'));


/**
* Add additional external limitation
Expand All @@ -477,7 +493,7 @@ protected function _getAttributes($storeId, array $entityIds, array $attributeTy
$eventName,
array(
'select' => $select,
'entity_field' => new Zend_Db_Expr('t_default.entity_id'),
'entity_field' => new Zend_Db_Expr('t_main.entity_id'),
'website_field' => $websiteId,
'store_field' => new Zend_Db_Expr('t_store.store_id')
)
Expand Down