Magento 按id更新制造商选项值

Magento 按id更新制造商选项值,magento,attributes,magento-1.7,Magento,Attributes,Magento 1.7,我需要更新属性选项标签id 我有一个csv,其中包含制造商标识和制造商标签 请让我知道如何以编程方式更新 $productid = 100; $productModel = Mage::getModel('catalog/product')->load($productid); $attr = $productModel->getResource()->getAttribute("manufacturer"); if ($attr->usesSource()) {

我需要更新属性选项标签id

我有一个csv,其中包含
制造商标识
制造商标签

请让我知道如何以编程方式更新

$productid = 100;
$productModel = Mage::getModel('catalog/product')->load($productid);
$attr = $productModel->getResource()->getAttribute("manufacturer");
if ($attr->usesSource()) {
    $manufacturer_label = $attr->getSource()->setOptionText("some_value")->save();
}

下面是更新数据库中制造商名称的代码

require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();

echo '<pre>';
$resource = Mage::getSingleton('core/resource');
$writeConnection = $resource->getConnection('core_write');
$table = $resource->getTableName('catalog/product');
// $productId = 44;
// $newSku = 'new-sku';
// $query = "UPDATE {$table} SET sku = '{$sku}' WHERE entity_id = "
//              . (int)$productId;
// $writeConnection->query($query);
function readCSV($csvFile){
    $file_handle = fopen($csvFile, 'r');
    while (!feof($file_handle) ) {
        $line_of_text[] = fgetcsv($file_handle, 1024);
    }
    fclose($file_handle);
    return $line_of_text;

}


// Set path to CSV file
$csvFile = 'manufacturer.csv';
$csv = readCSV($csvFile);
$filtered_array = array_filter($csv);

foreach ($filtered_array as $key => $value) {
    if($value[0]!='manufacturer_id'){
        // print_r($value);
        $new_name = $value[1];
        $option_id = $value[0];
        // UPDATE  `allday19Mat14`.`eav_attribute_option_value` SET  `value` =  'Cipla 2' WHERE  `eav_attribute_option_value`.`option_id` =102;
        $query = "UPDATE `eav_attribute_option_value` SET `value` = '{$new_name}' WHERE `eav_attribute_option_value`.`option_id` = "
              . (int)$option_id;
              // echo '<br/>';
        $writeConnection->query($query);
    }
}
Mage::getModel('index/process')->load(4)->reindexEverything();
exit();
require_once('app/Mage.php')//通往Magento的道路
乌马斯克(0);
Mage::app();
回声';
$resource=Mage::getSingleton('core/resource');
$writeConnection=$resource->getConnection('core_write');
$table=$resource->getTableName('catalog/product');
//$productId=44;
//$newSku=‘新sku’;
//$query=“更新{$table}集sku='{$sku}'其中实体_id=”
//              . (int)$productId;
//$writeConnection->query($query);
函数readCSV($csvFile){
$file_handle=fopen($csvFile,'r');
而(!feof($file_handle)){
$line_of_text[]=fgetcsv($file_handle,1024);
}
fclose($file\u handle);
返回\u文本的$line\u;
}
//设置CSV文件的路径
$csvFile='manufacturer.csv';
$csv=readCSV($csvFile);
$filtered\u array=array\u filter($csv);
foreach($key=>$value形式的过滤数组){
如果($value[0]!='manufacturer\u id'){
//打印(价值);
$new_name=$value[1];
$option_id=$value[0];
//更新'allday19Mat14'。'eav\u属性选项选项值'SET'value`='Cipla 2',其中'eav\u属性选项选项选项值'。'option\u id`=102;
$query=“UPDATE`eav\u attribute\u option\u value`SET`value`='{$new\u name}'其中`eav\u attribute\u option\u value`.`option\u id`=”
(int)$option_id;
//回声“
”; $writeConnection->query($query); } } Mage::getModel('index/process')->load(4)->reindexeverythings(); 退出();