久久久久久久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)
主站蜘蛛池模板: 久久精品国产免费高清 | 99精品视频在线观看免费播放 | www.国产精 | 最新日韩精品 | 九九热视频这里只有精品 | 日韩精品视频在线观看一区二区三区 | 一区二区三区欧美 | 日本黄色的视频 | 亚洲欧美一区二区三区在线 | 一区二区三区四区视频 | 久久久69| 欧洲免费毛片 | 最新中文字幕 | 新超碰97 | 免费看片国产 | 欧美一级在线 | 天堂一区二区三区 | 播放一级黄色片 | 国产美女h视频 | 三级欧美| 精品视频在线播放 | 99久久免费精品国产免费高清 | 日韩精品久久久久久 | 欧美激情一区二区三级高清视频 | 午夜性色a√在线视频观看9 | va精品 | 日本一区二区三区四区 | 国产农村妇女精品一区 | 99久热| 欧美一区二区三区在线看 | 欧美中文在线 | 特级特黄特色的免费大片 | 亚洲国产欧美国产综合一区 | 日本精品一区二区在线观看 | 成人一区二区三区在线观看 | 激情的网站 | 国产区在线 | 欧美日韩一区在线 | 欧美成人手机视频 | 精品一二三区 | 一区二区日本 |