简体   繁体   English

Magento Community 1.7.0.2 - 导出产品CSV

[英]Magento Community 1.7.0.2 - Export Products CSV

Quite a new install of Magento, Products are setup etc and was just about to export a product CSV and once I submitted the normal form, The error "No valid data sent" I started doing some debug to see what was going off. 相当新的Magento安装,产品设置等,即将导出产品CSV,一旦我提交了正常的表格,错误“没有有效的数据发送”我开始做一些调试,看看是什么发生了。 First stop was the exception.log 第一站是例外.log

Notice: Undefined index:   in /app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php on line 539' in /app/code/core/Mage/Core/functions.php:245

The function thats causing the problem is: 导致问题的功能是:

/**
 * Update data row with information about categories. Return true, if data row was updated
 *
 * @param array $dataRow
 * @param array $rowCategories
 * @param int $productId
 * @return bool
 */
protected function _updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $productId)
{
    if (!isset($rowCategories[$productId])) {
        return false;
    }

    $categoryId = array_shift($rowCategories[$productId]);
    $dataRow[self::COL_ROOT_CATEGORY] = $this->_rootCategories[$categoryId];
    if (isset($this->_categories[$categoryId])) {
        $dataRow[self::COL_CATEGORY] = $this->_categories[$categoryId];
    }

    return true;
}

For somereason, $categoryId doesn't get set as $rowCategories isn't an Array. 对于某些原因,$ categoryId没有设置为$ rowCategories不是数组。

I've re-run the index management just incase, but it seems to me like theres something wrong with the Categories or something. 我刚刚重新运行了索引管理,但在我看来,类似于类别或类似的东西。 I know a quick fix is to check that the $categoryId is set before continuing, but I'd like to know what's causing the error in the first place. 我知道快速修复是在继续之前检查$ categoryId是否已设置,但我想首先知道是什么导致了错误。

Until a fix from magento, you can duplicate the file under 在magento修复之前,您可以复制文件
local/Mage/ImportExport/Model/Export/Entity/Product.php

and change line 534: 并更改第534行:

if (!isset($rowCategories[$productId])) {
    return false;
}

to

if (!isset($rowCategories[$productId]) or empty($rowCategories[$productId])) {
    return false;
}

I had the same problem. 我有同样的问题。 As I was only trying to export one product - the fix was easy: I just added the product to a category. 由于我只是尝试导出一个产品 - 修复很简单:我只是将产品添加到一个类别中。

There seems to be something wrong with the filters on the export products' form. 出口产品表格上的过滤器似乎有问题。 The simple fix for this, on magento 1.7.0.2: 对magento 1.7.0.2的简单修复:

  1. Copy the file app/code/core/Mage/ImportExport/Model/Export.php to app/code/local/Mage/ImportExport/Model/Export.php . 将文件app / code / core / Mage / ImportExport / Model / Export.php复制app / code / local / Mage / ImportExport / Model / Export.php
  2. Around line 145, on the export() method, comment out the if, and the else. 在第145行,在export()方法上,注释掉if和else。 There is never a filter on the form. 表单上永远不会有过滤器。
  3. Copy the file app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php to app/code/local/Mage/ImportExport/controllers/Adminhtml/ExportController . 将文件app / code / core / Mage / ImportExport / controllers / Adminhtml / ExportController.php复制到app / code / local / Mage / ImportExport / controllers / Adminhtml / ExportController
  4. Around line 77, on the exportAction() method, comment out the if and the else. 在第77行,在exportAction()方法上,注释掉if和else。 Same reason as above 与上述相同的原因

That did it for me. 这样做对我来说。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM