私はしばらくの間フロントエンドマジェントをやっていましたが、ただモジュールを構築し始めました。これは私がフロントエンドを行う方法を知っている何かですが、私は自分のモジュールで苦労しています。私が現在達成しようとしているのは、利用可能なすべてのプロダクト属性を持つ管理者のマルチセレクションです。すべての製品属性セットにカスタム製品属性を含める。フラット・カテゴリー・データが有効であると仮定したくないので、どのテーブルが必要なのかは完全にはわかりません。すべての製品属性のリストをmagentoで取得
システム設定の新しいタブで管理領域を作成しましたが、現在は3つの静的オプションが設定されている複数選択フィールドが作成されています。これは多くの作品。誰かが正しい方向に指を指して私を助けることができます...現在これは私がこれまで持っていたものです(価値があるもののためです)。
<?php
class test_test_Model_Source
{
public function toOptionArray()
{
return array(
array('value' => 0, 'label' =>'First item'),
array('value' => 1, 'label' => 'Second item'),
array('value' => 2, 'label' =>'third item'),
);
}
}
///////////////////////////// EDIT ///////////// ////////////////////////
私はここに何かがあるように感じますが、すべての属性の最初の文字を返すだけですそのさえ属性はそのが戻った場合、私は
public function toOptionArray()
{
$attributes = Mage::getModel('catalog/product')->getAttributes();
$attributeArray = array();
foreach($attributes as $a){
foreach($a->getSource()->getAllOptions(false) as $option){
$attributeArray[$option['value']] = $option['label'];
}
}
return $attributeArray;
}
)わからないんだけど////////////////////////////// /// EDIT /////////////////////////
私は極端ではない私はそれがすべてのattribute_codesに、私はそれが欲しいものを返す配列を知っているように閉じる。しかし、それはまだそれぞれの最初の文字を出力している...誰でも知っている理由は?
public function toOptionArray()
{
$attributes = Mage::getModel('catalog/product')->getAttributes();
$attributeArray = array();
foreach($attributes as $a){
foreach ($a->getEntityType()->getAttributeCodes() as $attributeName) {
$attributeArray[$attributeName] = $attributeName;
}
break;
}
return $attributeArray;
}
上記の編集を参照してください^^ –
あなたは配列のprint_rの一部を投稿できますか? – Mat
だから私はそれを返す二foreachループの$ attributeNameの中にログイン:: MAGE場合:allow_message DEBUG(7):allow_open_amount DEBUG(7):AW_commission_group DEBUG(7):(7) DEBUG box_depth DEBUG( 7):box_height DEBUG(7):box_weight DEBUG(7):box_width DEBUG(7):ブランド DEBUGは(7): DEBUG(7)can_be_gift_wrapped:category_ids を..... しかし、私が配列を返すとき、multiselectオプションは各属性の最初の文字を表示します。コード –