4

「製品リストで使用」が YES にチェックされている属性を知りたいのですが、$attribute->getIsVisibleOnFront() のような関数が見つかりません。

実際、属性の「フロントエンド プロパティ」からオプション値を取得する方法がわかりません (クイック検索で使用、高度な検索で使用、...)

私のコードは次のようなものです:

<?php $attributes = $_product->getAttributes();             
    foreach ($attributes as $attribute) {
        if ($attribute->getIsUsedInProductListing()) {
                       echo $attribute->getStoreLabel();
                    }
            }
    ?>

getIsUsedInProductListing() は存在しません ;-)

ありがとう...

4

1 に答える 1

5

はい、これは非常に簡単です。

$product = Mage::getModel('catalog/product')->load($productId); // Or, use your product
$attributes = $product->getTypeInstance(true)->getSetAttributes($product);

foreach ($attributes as $attribute){
     var_dump($attribute); // You will be able to see all of the attribute settings here.

     if ($attribute->getUsedInProductListing()) {
          // Do cool things here.
     }

     if ($attribute->getIsHtmlAllowedOnFront()) {
          // Do cool things here.
     }

     if ($attribute->getIsVisibleInAdvancedSearch()) {
          // Do cool things here.
     }

     if ($attribute->getUsedForSortBy()) {
          // Do cool things here.
     }
}
于 2012-11-26T21:14:08.917 に答える