以下のコードは、製品コレクションを作成してフィルタリングしようとしていますが、正確な製品数が得られないため、理由がわかりません。
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*')
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
->addFieldToFilter(array(
array('attribute'=>'distributor','in'=>array(intval($distributor))),
))
->addAttributeToFilter('category_id', array(
array('finset' => strval($cat->getId())),
));
$count = $collection->getSize();
たとえば、そのディストリビューターフィルターに約30の商品があるカテゴリがありますが、上記のコードのカウントは20を示しています。3つの商品があるがそのカウントが2に戻る別のカテゴリについても同じです。
更新:代わりにfinsetを使用して自分で問題を修正しました。以下の私の答えを参照してください