After we turn on Use Flat Catalog Product, we activate the catalog_product_flat index.
Run bin/magento indexer:reindex catalog_product_flat
A new table catalog_product_flat_<storeId>
will be created.
In this table, product eav attributes which are configured as Used in Product Listing are added as columns.
Let’s see how this worked.
<indexer id="catalog_product_flat" view_id="catalog_product_flat" class="Magento\Catalog\Model\Indexer\Product\Flat">
<title translate="true">Product Flat Data</title>
<description translate="true">Reorganize EAV product structure to flat structure</description>
</indexer>
Magento\Catalog\Model\Indexer\Product\Flat:executeFull
> Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction:_updateRelationProducts
> Magento\Catalog\Helper\Product\Flat\Indexer:getFlatColumns
public function getFlatColumns()
{
if ($this->_columns === null) {
$this->_columns = $this->getFlatColumnsDdlDefinition();
foreach ($this->getAttributes() as $attribute) {
/** @var $attribute \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */
$columns = $attribute->setFlatAddFilterableAttributes(
$this->isAddFilterableAttributes()
)->setFlatAddChildData(
$this->isAddChildData()
)->getFlatColumns();
if ($columns !== null) {
$this->_columns = array_merge($this->_columns, $columns);
}
}
}
return $this->_columns;
}
Practice Tests
What is the purpose of the getFlatColumns method in an EAV’s Source model?
A. It returns a list of columns in the entity’s _text table.
B. It converts option values into row values for the attribute value tables.
C. It flattens an array attribute value into a JSON string.
D. It returns columns that will be added to the EAV model’s flat table.
Answer D