2

Could you please help me posting the following issue I have in Magento Community Edition 1.8.1:

"I have issues when exporting the Product Catalog in Community Edition 1.8.1, I have 100,000 items, and the error I get is this:

2014-10-08T18:00:09+00:00 ERR (3):
exception 'Exception' with message 'Notice: Undefined offset: 103041  in app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php on line 875$
Stack trace:
#0 app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php(875): mageCoreErrorHandler(8, 'Undefined offse...', '/var/inetpub-lo...', 875, Ar$
#1 app/code/core/Mage/ImportExport/Model/Export.php(150): Mage_ImportExport_Model_Export_Entity_Product->export()
#2 app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php(86): Mage_ImportExport_Model_Export->export()
#3 app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_ImportExport_Adminhtml_ExportController->exportAction()
#4 app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('export')
#5 app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_$
#6 app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#7 app/Mage.php(684): Mage_Core_Model_App->run(Array)
#8 index.php(86): Mage::run('', 'store')
#9 {main} 

Does anybody have a clue about this?

1
  • Hi Cinthya and welcome to MageOverflow. If you have two questions - and it seems like it, please post two questions. Commented Oct 22, 2014 at 21:42

2 Answers 2

3

I have seen similar behavior coming from M2EPro imported listings. What it seems to do it drop the shipping field data. So I just sorted the grid by weight, found any empties and corrected the shipping weight. The error I got was:

Notice: Undefined offset: 3347 in /home/builders/public_html/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php on line 875

Note the offset is actually the products internal magento ID, so your offset of 103041 is the products ID, edit and resave that item in the backend and try to export again... The export should continue to the next record. Worked for me.

0

I have no idea how to fix this. But the error which is raised here:

if ($defaultStoreId != $storeId) {
    $dataRow[self::COL_SKU]      = null;
    $dataRow[self::COL_ATTR_SET] = null;
    $dataRow[self::COL_TYPE]     = null;
} else {
    $dataRow[self::COL_STORE] = null;
    $dataRow += $stockItemRows[$productId]; // THIS LINE
}

tries to access an array key which encodes a product id in an array which should contain stock informations, but obviously doesn't.

The array is built here:

\Mage_ImportExport_Model_Export_Entity_Product::_prepareCatalogInventory
protected function _prepareCatalogInventory(array $productIds)
{
    if (empty($productIds)) {
        return array();
    }
    $select = $this->_connection->select()
        ->from(Mage::getResourceModel('cataloginventory/stock_item')->getMainTable())
        ->where('product_id IN (?)', $productIds);

    $stmt = $this->_connection->query($select);
    $stockItemRows = array();
    while ($stockItemRow = $stmt->fetch()) {
        $productId = $stockItemRow['product_id'];
        unset(
            $stockItemRow['item_id'], $stockItemRow['product_id'], $stockItemRow['low_stock_date'],
            $stockItemRow['stock_id'], $stockItemRow['stock_status_changed_automatically']
        );
        $stockItemRows[$productId] = $stockItemRow;
    }
    return $stockItemRows;
}

All stock informations from database are read and written in this array. So maybe your product with id 103041 just doesn't have a stock item. You can check easily in catalog_inventory_stock_item table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.