Magento 产品从 csv 文件导入

发布于 2024-09-25 23:00:06 字数 169 浏览 2 评论 0原文

我想从我的 csv 文件导入 Magento 产品,但是当我导入此 csv 文件时,我收到这样的错误(跳过导入行,未定义必填字段“sku”)但是,我在 csv 文件中定义了此字段。

如果有人对此有任何想法,请告诉我。我应该遵循哪种方法将我的 csv 产品导入 Magento

提前感谢您的帮助

I want to import Magento products from my csv file, but when I import this csv file I get an error like this ( Skip import row, required field "sku" not defined) However, I had this field defined in my csv file.

If any one has any idea about that then please advise me. Which method should I follow to import my csv products to Magento

Thanks for help in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白衬杉格子梦 2024-10-02 23:00:06

我发现这个解决方案非常简单:

  1. 只需转到系统->导入/导出,然后通过 csv 导出所有产品

  2. 现在在 csv 中输入您需要的所有其他字段或属性数据。

  3. <前><代码>setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
    $product = Mage::getModel('目录/产品');
    $product->setSku($data[5]);
    $product->setName($data[7]);



    尝试 {
    $产品->保存();
    回声'
    您好,产品已成功保存在 magento uniqe 移动商店中';
    }
    捕获(异常$ex){
    echo '处理错误';
    }

    }// if 语句存储结束
    }// while 循环结束
    fclose($句柄);
    ?>

使用此代码并设置所有产品,但所有字段均根据您的 CSV 文件设置。然后运行这段代码。
我测试了这段代码,它的工作原理。这是我自己的创作

I find this solution its very simple:

  1. just go to system->import/export and then u export all product by csv

  2. now enter all other fields or attribute data in csv which u required.

  3. <?php
    set_time_limit(0);
    define('MAGENTO_MAGE_LOCATION','/your site name path/app/Mage.php');
    error_reporting(E_ALL);
    $handle = fopen("your csv name path.csv", "r");
    $count=0;
    while (($data = fgetcsv($handle)) !== FALSE)
    {
      $count++;
      if($data[0] != 'store')
      {
        require_once MAGENTO_MAGE_LOCATION;
        Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
        $product = Mage::getModel('catalog/product');
        $product->setSku($data[5]);
        $product->setName($data[7]);
         .
         .
         .
        try {
          $product->save();
          echo '<br> hi product save successfully in magento uniqe mobile store';
        }
        catch (Exception $ex) {  
          echo 'Handle the error';
        }
    
      }// end of if statment store 
    }// end of while loop 
    fclose($handle);
    ?>
    

use this code and set all products but all fields set acourding to ur CSV file. then run this code .
its working i test this code. its my own creation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文