I need to export all the products in Magento 1.9 with the module Mage_ImportExport, but in export setting
when I select product
as Entity Type
, Magento doesn't load any Entity Attributes
.
So when I click on "Continue" I get the error "No valid data sent"
I've checked the web server log file that gives this error:
PHP Fatal error: Call to a member function getName() on a non-object app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php on line 171
the error part of that Product.php
is:
/**
* Initialize categories ID to text-path hash.
*
* @return Mage_ImportExport_Model_Export_Entity_Product
*/
protected function _initCategories()
{
$collection = Mage::getResourceModel('catalog/category_collection')->addNameToResult();
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
foreach ($collection as $category) {
$structure = preg_split('#/+#', $category->getPath());
$pathSize = count($structure);
if ($pathSize > 1) {
$path = array();
for ($i = 1; $i < $pathSize; $i++) {
$path[] = $collection->getItemById($structure[$i])->getName();
}
$this->_rootCategories[$category->getId()] = array_shift($path);
if ($pathSize > 2) {
$this->_categories[$category->getId()] = implode('/', $path);
}
}
}
return $this;
}
and the line 171 is:
$path[] = $collection->getItemById($structure[$i])->getName();
any suggestions?
Best Answer
Before this try please try to do re-index data and check again.
The issue is $structure[$i] that is entity_id (category id) passing in this function. It seems entity_id is not a valid in catalog_category_entity or category flat tables.
Check in your database if your flat tables are fine.
Alternative but a not a good solution.
Replace this with