"Can't retrieve entity config: catalog/product_link_attribute_" while full index for products
cewald opened this issue · comments
If I run php shell/vsf_tools.php --action full_reindex --action full_reindex --store 1 --type products
the following exception is thrown:
PHP Fatal error: Uncaught Mage_Core_Exception: Can't retrieve entity config: catalog/product_link_attribute_ in /var/www/magento/public/app/Mage.php:598
Stack trace:
#0 /var/www/magento/public/app/code/core/Mage/Core/Model/Resource.php(282): Mage::throwException('Can't retrieve ...')
#1 /var/www/magento/public/app/code/community/Divante/VueStorefrontIndexer/Model/Resource/Catalog/Product/Links.php(192): Mage_Core_Model_Resource->getTableName('catalog/product...')
#2 /var/www/magento/public/app/code/community/Divante/VueStorefrontIndexer/Model/Resource/Catalog/Product/Links.php(172): Divante_VueStorefrontIndexer_Model_Resource_Catalog_Product_Links->joinPositionAttribute(Object(Varien_Db_Select))
#3 /var/www/magento/public/app/code/community/Divante/VueStorefrontIndexer/Model/Resource/Catalog/Product/Links.php(129): Divante_VueStorefrontIndexer_Model_Resource_Catalog_Product_Links->prepareLinksSelect()
#4 /var/www/magento/public/app/code/community/Divante/VueStorefrontIndexer/Model/Resource/Catalog/Product/Links.php(85): Divan in /var/www/magento/public/app/Mage.php on line 598
Reason:
I found out that this happens because our catalog_product_link_attribute
table is empty and the select is return false instead of an array in class method Divante_VueStorefrontIndexer_Model_Resource_Catalog_Product_Links::fetchPositionAttributeData()
(line 209-220, source link).
Solution
I changed the class method joinPositionAttribute()
to continue if an empty array is returned by fetchPositionAttributeData()
:
/**
* @param Varien_Db_Select $select
*
* @return Varien_Db_Select
*/
private function joinPositionAttribute(Varien_Db_Select $select)
{
$alias = 'link_position';
$attributePosition = $this->fetchPositionAttributeData();
if (empty($attributePosition)) {
return $select;
}
$table = $this->resource->getTableName($this->getAttributeTypeTable($attributePosition['type']));
$joinCondition = [
"{$alias}.link_id = links.link_id",
$this->connection->quoteInto(
"{$alias}.product_link_attribute_id = ?",
$attributePosition['id']
),
];
$select->joinLeft(
array($alias => $table),
implode(' AND ', $joinCondition),
array($attributePosition['code'] => 'value')
);
return $select;
}
Maybe this should be considered in the code by default if somebody isn't using upsell- or crosssell-products.
Thanks for pointing this out! Can You propose a PR with this change please?
@afirlejczyk Alright. As i know these tables are used to save "non-eav" product relations like cross-sell, up-sell or grouped products – if you don't have them in use, this tables are empty. But if you use the sample data of magento, there will be sample data in this tables after installation. I double checked it with a plain installation with sample data. But it's definitely good to be sure ;)