Magento Advanced custom section for CSV table import features!

Source: Internet
Author: User
Tags cdata

Magento self with Import and export function

Backstage system-->import/export-->advanced Profiles

Click Add New profiles after entering

You can create a new rule.

Profile Name * is a name

Actions XML * is the corresponding parameter

such as examples:

<action type= "Dataflow/convert_adapter_io" method= "Load" > <var name= "type" >file</var> <var na Me= "path" >var/import</var> <var name= "filename" ><! [cdata[configproduct.csv]]></var> <var name= "format" ><! [cdata[csv]]></var> </action> <action type= "dataflow/convert_parser_csv" method= "Parse" > < var name= "delimiter" ><! [cdata[,]]></var> <var name= "Enclose" ><! [cdata["]]></var> <var name=" FieldNames ">true</var> <var name=" Store "><! [cdata[0]]></var> <var name= "number_of_records" >1</var> <var name= "root_catalog_id" >&lt ;! [cdata[2]]></var> <var name= "Reimport_images" ><! [cdata[true]]></var> <var name= "Deleteall_andreimport_images" ><! [cdata[true]]></var> <var name= "Exclude_images" ><! [cdata[false]]></var> <var name= "Exclude_Gallery_images "><! [cdata[false]]></var> <var name= "Decimal_separator" ><! [cdata[.]] ></var> <var name= "adapter" >catalog/convert_adapter_productimport</var> <var name= "method" >parse</var> </action>

Analytical:

File is a document type

Path is the CSV file paths

FileName is the CSV file name

Format is CSV

The following configuration is the appropriate file format

With him, you can import the data you want to import, that is, Magento implemented this CSV import framework, in the corresponding file

Catalog/convert_adapter_productimport

Public function Saverow (array $importData) function inside $importdata

This data is a row in the CSV file, and each column is an element in the array.

Then use the Magento mechanism to save it.

Above I am just a general one said, specific research, you can download a free magento import and export plugin. Then we look at the code inside, and then we'll look at how to insert the data, such as writing a function to bulk import tags into an existing product, for example:

<?php/** * Magento * * NOTICE of LICENSE * * This source file was subject to the Open software LICENSE (OSL 3.0)
 * That's bundled with the the file LICENSE.txt.  * It's also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you do Not receive a copy of the license and is unable to * obtain it through the World-wide-web, please send a mail * to L
 icense@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * does not edit or add to this file if you wish to upgrade Magento to newer * versions in the future.
 If you wish to customize Magento for your * needs, refer to http://www.magentocommerce.com for more information. * * @category Mage * @package mage_catalog * @copyright Copyright (c) Magento Inc. (http://www.magentocom merce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software license (OSL 3.0) */class Mage_ca Talog_model_convert_adapter_productimport extends Mage_eav_model_convert_adapter_entity {public Function parse () {
        $batchModel = Mage::getsingleton (' Dataflow/batch ');
        /* @var $batchModel mage_dataflow_model_batch */$batchImportModel = $batchModel->getbatchimportmodel ();

        $importIds = $batchImportModel->getidcollection (); foreach ($importIds as $importId) {//print ' <pre> '. Memory_get_usage (). '
            </pre> ';
            $batchImportModel->load ($importId);

            $importData = $batchImportModel->getbatchdata ();
        $this->saverow ($importData);  }} Public Function Saverow (array $importData) {$default _type = 1;//amazon $default _status = 1;
		Weicaiji if (!isset ($importData [' type '])) {$type = $default _type;
		}else{$type = $importData [' type '];
        } $create _date_time = Mage::getmodel ("Core/date")->date ("y-m-d h:i:s"); if (Isset ($importData [' SKU ']) && $importData [' sku ']! = "") {$sku = $importData [' SKU '];
			$no = $importData [' No '];
			$pro _sku = Mage::getmodel ("Getreview/sku"); $pro = $pro _sku->getcollection ()->addfieldtofilter ("SKU", Array ("eq" = + $type))->addfieldtofilte
			R ("No", Array ("eq" = $no))->addfieldtofilter ("type", Array ("eq" = $type))->getfirstitem (); if ($pro->getid ()) {$this->addexception ("This SKU:". $sku. ", No:". $no. ", type:". $type. "
				s exist; ");
			return ture; try {$pro _sku->settype ($type)->setstatus ($default _status)->setcreate
            
            DateTime ($create _date_time)->setsku ($sku)->setno ($no)->save (); }catch (Exception $e) {}} R
    Eturn true;
 }
	
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.