久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 Magento 中以編程方式更新屬性選項?

How to update the attribute options programmatically in Magento?(如何在 Magento 中以編程方式更新屬性選項?)
本文介紹了如何在 Magento 中以編程方式更新屬性選項?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想通過代碼(以編程方式)更新/添加 Magento 中下拉屬性的選項.我已經找到了如何添加屬性選項,但如何更新選項值.
示例:
假設屬性是制造商".我添加了三個選項 man1、man2、man3.現在通過我的自定義代碼,我想將 man1 的標簽更改為 man11,將 man2 的標簽更改為 man22.我怎樣才能做到這一點?謝謝.

I want to update/add the options of a drop down attribute in Magento though code (programmatically). I have found how to add attribute options, but how can I update the option values.
Example:
Suppose the attribute is 'manufacturer'. I have added three options man1, man2, man3. Now through my custom code I want to change the label of man1 to man11 and man2 to man22. How can I achieve that? Thanks.

推薦答案

好吧,我自己找到了解決方案.在此處查看完整詳情.

Well, I found a solution myself. See complete details here.

//Get the eav attribute model
$attr_model = Mage::getModel('catalog/resource_eav_attribute');

//Load the particular attribute by id
//Here 73 is the id of 'manufacturer' attribute
$attr_model->load(73);

//Create an array to store the attribute data
$data = array();

//Create options array
$values = array(
    //15 is the option_id of the option in 'eav_attribute_option_value' table
    15 => array(
            0 => 'Apple'    //0 is current store id, Apple is the new label for the option
        ),
    16 => array(
            0 => 'HTC'
        ),
    17 => array(
            0 => 'Microsoft'
        ),
);

//Add the option values to the data
$data['option']['value'] = $values;

//Add data to our attribute model
$attr_model->addData($data);

//Save the updated model
try {
    $attr_model->save();
    $session = Mage::getSingleton('adminhtml/session');
    $session->addSuccess(
        Mage::helper('catalog')->__('The product attribute has been saved.'));

    /**
     * Clear translation cache because attribute labels are stored in translation
     */
    Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG));
    $session->setAttributeData(false);
    return;
} catch (Exception $e) {
    $session->addError($e->getMessage());
    $session->setAttributeData($data);
    return;
}

這篇關于如何在 Magento 中以編程方式更新屬性選項?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 黑人精品欧美一区二区蜜桃 | 成人三级电影 | 黄色av网站在线免费观看 | jizz在线免费观看 | 一区二区三区在线播放 | 欧美激情久久久 | 日本激情视频中文字幕 | 欧美激情国产日韩精品一区18 | 中文字幕一区二区三区在线观看 | 日韩一区二区在线播放 | 亚洲精品无 | 久久精品国产v日韩v亚洲 | 国产一区精品在线 | 中文字幕日本一区二区 | 久久久入口| 欧美精品成人 | 成人在线激情 | 日韩精品在线播放 | 久久999 | 欧美激情综合 | 成人国产精品久久久 | 亚洲三级在线 | 国产精品免费一区二区三区四区 | 国产综合视频 | 国产高清视频在线播放 | 91九色在线观看 | 人成在线视频 | 久久久一区二区 | 999观看免费高清www | 欧美日韩亚洲视频 | 黑人精品欧美一区二区蜜桃 | 91xxx在线观看| 欧美日韩一二三区 | 日美女逼逼 | 69精品久久久久久 | 国产成人免费视频网站视频社区 | 人人草人人干 | av在线天天 | 久久91精品国产一区二区 | 一区二区在线 | 一区二区三区在线观看免费视频 |