/** * Retrieve attributes load select * * @param string $table * @return Mage_Eav_Model_Entity_Collection_Abstract */ protected function _getLoadAttributesSelect($table) { if ((int) $this->getStoreId()) { $entityIdField = $this->getEntity()->getEntityIdField(); $joinCondition = 'store.attribute_id=default.attribute_id AND store.entity_id=default.entity_id AND store.store_id=' . (int) $this->getStoreId(); $select = $this->getConnection()->select()->from(array('default' => $table), array($entityIdField, 'attribute_id', 'default_value' => 'value'))->joinLeft(array('store' => $table), $joinCondition, array('store_value' => 'value', 'value' => new Zend_Db_Expr('IFNULL(store.value, default.value)')))->where('default.entity_type_id=?', $this->getEntity()->getTypeId())->where("default.{$entityIdField} in (?)", array_keys($this->_itemsById))->where('default.attribute_id in (?)', $this->_selectAttributes)->where('default.store_id = 0'); } else { $select = parent::_getLoadAttributesSelect($table)->where('store_id=?', $this->getDefaultStoreId()); } return $select; }
/** * Retrieve attributes load select * * @param string $table * @param array|int $attributeIds * @return Mage_Eav_Model_Entity_Collection_Abstract */ protected function _getLoadAttributesSelect($table, $attributeIds = array()) { if (empty($attributeIds)) { $attributeIds = $this->_selectAttributes; } $storeId = $this->getStoreId(); if ($storeId) { $adapter = $this->getConnection(); $entityIdField = $this->getEntity()->getEntityIdField(); $joinCondition = array( 't_s.attribute_id = t_d.attribute_id', 't_s.entity_id = t_d.entity_id', $adapter->quoteInto('t_s.store_id = ?', $storeId) ); $select = $adapter->select() ->from(array('t_d' => $table), array($entityIdField, 'attribute_id')) ->joinLeft( array('t_s' => $table), implode(' AND ', $joinCondition), array()) ->where('t_d.entity_type_id = ?', $this->getEntity()->getTypeId()) ->where("t_d.{$entityIdField} IN (?)", array_keys($this->_itemsById)) ->where('t_d.attribute_id IN (?)', $attributeIds) ->where('t_d.store_id = ?', 0); } else { $select = parent::_getLoadAttributesSelect($table) ->where('store_id = ?', $this->getDefaultStoreId()); } return $select; }
/** * Retrieve attributes load select * * @param string $table * @param array $attributeIds * @return Mage_Eav_Model_Entity_Collection_Abstract */ protected function _getLoadAttributesSelect($table, $attributeIds = array()) { $select = parent::_getLoadAttributesSelect($table, $attributeIds); if ($this->getStoreId()) { $select->where('store_id IN (?)', array(0, $this->getStoreId())); } else { $select->where('store_id = 0'); } $select->columns(array('store_id' => $table . '.store_id')); return $select; }