Smile\ElasticsuiteCatalog\Model\ResourceModel\Eav\Indexer\Fulltext\Datasource\AbstractAttributeData::getAttributesRawData PHP Method

getAttributesRawData() public method

Load attribute data for a list of entity ids.
public getAttributesRawData ( integer $storeId, array $entityIds, string $tableName, array $attributeIds ) : array
$storeId integer Store id.
$entityIds array Entity ids.
$tableName string Attribute table.
$attributeIds array Attribute ids to get loaded.
return array
    public function getAttributesRawData($storeId, array $entityIds, $tableName, array $attributeIds)
    {
        $select = $this->connection->select();
        // The field modelizing the link between entity table and attribute values table. Either row_id or entity_id.
        $linkField = $this->getEntityMetaData($this->getEntityTypeId())->getLinkField();
        // The legacy entity_id field.
        $entityIdField = $this->getEntityMetaData($this->getEntityTypeId())->getIdentifierField();
        $joinStoreValuesConditionClauses = ["t_default.{$linkField} = t_store.{$linkField}", 't_default.attribute_id = t_store.attribute_id', 't_store.store_id= ?'];
        $joinStoreValuesCondition = $this->connection->quoteInto(implode(' AND ', $joinStoreValuesConditionClauses), $storeId);
        $select->from(['entity' => $this->getEntityMetaData($this->getEntityTypeId())->getEntityTable()], [$entityIdField])->joinInner(['t_default' => $tableName], new \Zend_Db_Expr("entity.{$linkField} = t_default.{$linkField}"), ['attribute_id'])->joinLeft(['t_store' => $tableName], $joinStoreValuesCondition, [])->where('t_default.store_id=?', 0)->where('t_default.attribute_id IN (?)', $attributeIds)->where("entity.{$entityIdField} IN (?)", $entityIds)->columns(['value' => new \Zend_Db_Expr('COALESCE(t_store.value, t_default.value)')]);
        return $this->connection->fetchAll($select);
    }

Usage Example

コード例 #1
0
 /**
  * Load attribute data from the database.
  *
  * @param integer $storeId      Store id.
  * @param array   $entityIds    Entity ids.
  * @param string  $tableName    Attribute table name.
  * @param array   $attributeIds Loaded attribute ids.
  *
  * @return array
  */
 protected function loadAttributesRawData($storeId, array $entityIds, $tableName, array $attributeIds)
 {
     return $this->resourceModel->getAttributesRawData($storeId, $entityIds, $tableName, $attributeIds);
 }