0

I am using Magento 1.7.0.0 CE and have a few questions.

How can i get products by tag name?

Is there any method in Magento that takes tag name and returns products assigned to that tag (tags are made by admin and products are assigned to it)

I ideally am looking for Mage Core API to do this. Does Mage Core API include this functionality?

Many thanks, Pez

4

2 回答 2

1

You can just use the «addTag» filter to the collection:

$collection->addTagFilter($tagId);

That should do the trick.

于 2012-05-09T20:19:31.970 回答
1
$tagId = 3;  //Mage::getModel('tag/tag')->loadByName($tagName)->getId();

$collection = Mage::getResourceModel('tag/product_collection')
                    ->addAttributeToSelect('sku')
                    ->addAttributeToSelect('name')
                    ->addTagFilter($tagId);

print_r($collection->getData());
于 2012-09-24T19:13:48.487 回答