/**
  * Retrieve attributes load select
  *
  * @param string $table
  * @param array|int $attributeIds
  * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
  */
 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 = ?', $adapter->getIfNullSql('t_s.store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID));
     } else {
         $select = parent::_getLoadAttributesSelect($table)->where('store_id = ?', $this->getDefaultStoreId());
     }
     return $select;
 }