Magentoのドロップダウン属性のオプションを(プログラムで)コードを使って更新/追加したい。属性オプションを追加する方法を見つけましたが、オプション値をどのように更新できますか?
例:
属性が「製造元」であるとします。私は3つのオプションman1、man2、man3を追加しました。今私のカスタムコードを介して、man1とman2のラベルをman22に変更したいと思います。それをどうすれば実現できますか?おかげさまで Magentoで属性オプションをプログラムで更新するにはどうすればよいですか?
1
A
答えて
2
まあ、自分で解決策を見つけました。 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;
}
0
app \ code \ core \ Mage \ Adminhtml \ controllers \ Catalog \ Product \ AttributeController.phpにあるAttributeControllerを拡張し、必要に応じてsaveAction()
メソッドをオーバーライドするとよいでしょう。
関連する問題
- 1. Magentoで属性オプションを削除するにはどうすればよいですか?
- 2. カートの更新でカートの追加属性を更新するにはどうすればよいですか?
- 3. Magento属性をプログラムで更新しています
- 4. WebViewでプログラムでテキスト属性を変更するにはどうすればよいですか?
- 5. GNUradioのフローでプログラムで属性を変更するにはどうすればよいですか?
- 6. アプリケーションをプログラムで更新するにはどうすればよいですか?
- 7. C#でSQLiteレコードの属性を更新するにはどうすればよいですか?
- 8. sequelizeでthrough-NM属性を更新するにはどうすればよいですか?
- 9. Spring CrudRepositoryで属性を更新するにはどうすればよいですか?
- 10. 1つのラジオボタンで2つの属性を更新するにはどうすればよいですか?
- 11. list.phtmlでカスタムMagento属性を取得するにはどうすればよいですか?
- 12. Magento:属性セットから属性をプログラムで削除する
- 13. ユーザー属性を更新するAWS Cognitoアクセストークンを取得するにはどうすればよいですか?
- 14. 角2:コンポーネントの属性の属性変更を検出するにはどうすればよいですか?
- 15. Magentoでオーダーライフサイクルを変更するにはどうすればよいですか?
- 16. JSPのモデル属性をAJAXレスポンスから更新するにはどうすればよいですか?
- 17. MSBuildスクリプトからXML属性を更新するにはどうすればよいですか?
- 18. プログラムで作成されたボタンの属性を設定するにはどうすればよいですか?
- 19. Magentoでスーパー属性を更新するには?
- 20. 属性を検索してhtmlを更新するにはどうすればよいですか?
- 21. Cocoaの印刷ダイアログで「ページ属性」オプションを取得するにはどうすればよいですか?
- 22. web.configの属性 "maxAllowedContentLength"からプログラムで値を取得するにはどうすればよいですか?
- 23. 製品属性と属性オプションはMagentoデータベースにどのように格納されますか?
- 24. ブラウザウィンドウで開いているNeo4jグラフをプログラムで更新するにはどうすればよいですか?
- 25. Magento属性と属性セットをプログラムで追加する
- 26. RegularExpression属性にmultilineオプションを追加するにはどうすればよいですか?
- 27. Magento - "Secondary Email"の顧客属性でログインするにはどうすればいいですか?
- 28. 受け入れテストを実行する前に属性オブジェクトの属性を更新するにはどうすればよいですか?
- 29. 変更をプログラムでチェックするにはどうすればよいですか?
- 30. プログラムでタブを変更するにはどうすればよいですか?
saveAction()では、すべての設定を属性に設定する必要があります。しかし、他の設定ではなくオプションラベルを更新したいだけです。 –