両方のストアのルート カテゴリは異なります。メインストアはデフォルトのサンプルデータで、セカンドストアには 1 つの製品だけが追加されました。ストア フィルターを使用すると、現在のストアのルート カテゴリ内の製品のみが表示されると思っていたでしょう。しかし、私はすべての製品を表示しています。カテゴリ ビュー テンプレートに以下を配置して、これをテストしています。
$store_id = Mage::app()->getStore()->getId();
$_testproductCollection = Mage::getResourceModel('reports/product_collection')
->setStoreId($storeId)
->addStoreFilter($store_id)
->addAttributeToSelect('*');
$_testproductCollection->load();
foreach($_testproductCollection as $_testproduct){
echo $this->htmlEscape($_testproduct->getName());
};
店舗 ID を印刷すると、正しい番号が表示されます。2 番目の Store に商品が 1 つしかないのに、すべてのストアからすべての商品が返品されるのはなぜですか? Main Store のすべての製品を Store2 に表示しないように設定してから、可視性フィルターを追加できますが、それには時間がかかります。
また、製品ストア ID をエコーすると、割り当てられているストアではなく、現在の ID が取得されることに気付きました。
echo $_testproduct->getStoreId()
この問題を解決するには?