Теги для импортируемого формата должны выглядеть следующим образом
![TagSpreadsheet](https://i.stack.imgur.com/3VXhB.png)
И поместите таблицу примерно в root/tagimport/tagsheet.csv
и вставьте следующий код в root/tagimport/importtag.php
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/../app/Mage.php';
Mage::app();
$fileName = 'importtag.csv';
getAttributeCsv($fileName);
function getAttributeCsv($fileName){
$file = fopen($fileName,"r");
$RemoveLine = 0;
while(!feof($file)){
$data = fgetcsv($file);
if($RemoveLine != 0){
$labelText[] = $data[1];
}$RemoveLine++;
}createAttribute($labelText);
fclose($file);
}
function createAttribute($labelText)
{
foreach($labelText as $tag){
if($tag){
$quote = Mage::getModel('tag/tag');
$quote->loadByName($tag);
if(!$quote->getId()){
$quote->setName($tag);
$quote->setStatus(1);
$quote->setFirstStoreId(0);
$quote->setPopularity(0);
$quote->save();
##### Save product tags in "tag_properties"
$connectionresource = Mage::getSingleton('core/resource');
$connectionWrite = $connectionresource->getConnection('core_write');
$table = 'tag_properties';
$query = "insert into ".$table." "."(tag_id,store_id,base_popularity) values "."(:tag_id, :store_id, :base_popularity)";
$binds = array(
'tag_id' => $quote->getTagId(),
'store_id' => '1',
'base_popularity' => '0',
);
$connectionWrite->query($query, $binds);
echo 'Tags Imported Successfully';
}
}
}
}
запустите указанный выше php-файл, используя
www.yourdomain.com/tagimport/importtag.php