I'm trying to search for all the tags assigned to a particular product, and using this code to do so:
$model = Mage::getModel('tag/tag'); $prod_collection = $model->getResourceCollection() ->addPopularity() ->addStatusFilter($model->getApprovedStatus()) ->addProductFilter((int) $productId) ->setFlag('relation', true) ->addStoreFilter((int) $store['id']) ->setActiveFilter() ->load();
$store['id'] is 1, and
$productId is 13065 (a product that I assigned a couple of tags directly using the backend).
As you can see the product has a couple tags assigned on store = 1, and another one assigned on store = 9.
But the above search returns an empty set. I checked the produced SQL and I see that what I'm getting is:
SELECT `main_table`.*, `summary_store`.* FROM `tag` AS `main_table` LEFT JOIN `tag_relation` AS `relation` ON main_table.tag_id = relation.tag_id LEFT JOIN `tag_summary` AS `summary_store` ON main_table.tag_id = summary_store.tag_id WHERE (main_table.status = 1) AND (`relation`.`product_id` = 13065) AND (summary_store.store_id IN (1)) AND (relation.store_id IN (1)) AND (relation.active = 1) GROUP BY `main_table`.`tag_id`, `main_table`.`tag_id`
where apparently every summary line is stored with store_id = 0, instead of saving one line per store.
How can I change my search so it doesn't join against
tag_summary, and only against
tag_relations? Does the content of my
tag_summary look alright, or should I have a summary line per each store view?
It would seem that the problem is that the corresponding summary lines aren't being generated. I created my tags using the admin, in Catalog->Manage Tags, and assigned the tags to arbitrary products, but it only creates the summary lines for Store ID 0... :(