あなたの質問への答えは、あなたが望むものを提供するために石鹸に頼るのではなく、あなたが望むものを手に入れる手段を提供するために石鹸を使うことです. これを考える方法は次のとおりです。
- カテゴリ内の製品 ID のリストを提供するように SOAP に依頼します。
- そのリストを使用して製品コレクションを読み込みます
- ニーズに基づいて製品コレクションをフィルタリングします
Magento と同じサーバー上で実行されるコードを作成している場合は、次の手順を実行するだけです。
- 「靴」という属性セットを作成します
- shoe_type というドロップダウン属性を作成し、フィルタリングする靴の種類 (ナイキ、リーボックなど) ごとにオプションを追加します。ドロップダウン属性 ID に注意してください。
- Magento ルート ディレクトリの test.php ファイルで次のコードを使用します。私はそれをテストしましたが、動作します。
アイデアは、カテゴリの「IN」に基づいてコレクションを作成し、特定の属性に基づいてそれらをフィルタリングするというものです。
echo "<PRE>";
umask(0);
// MAKE SURE TO PUT THIS FILE IN THE RIGHT PLACE (MAGENTO ROOT)
require_once 'app/Mage.php';
Mage::app('admin');
$attributeSetId = '26'; // Your attribute set id (shoes)
$shoeTypeId = '1'; // The ID of the dropdown item to filter on (taken from the ids of the items you added to the shoe_type attribute
// Create a collection based on a catalog category. Load category ID 196
$products = Mage::getModel('catalog/category')->load(196)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('attribute_set_id', $attributeSetId)
->addAttributeToFilter('type_id', 'simple')
->addAttributeToFilter('shoe_type', $shoeTypeId);
foreach ($products as $product)
{
// Write out the useful info!
var_dump($product->debug());
}
この方法を使用すると、ほぼ 100 倍高速になるだけでなく、magento のオブジェクト モデルをより明確に操作できます。Soap は、サーバーからサーバーへの通信や、magento Linux ボックスと通信する Windows マシンが必要な場合 (同期サービスの場合と同様) に便利です。