在Magento中为产品添加标签 [英] Adding tags to products in Magento

查看:97
本文介绍了在Magento中为产品添加标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Magento中将标签插入产品的代码是什么?

what is the code needed to insert tags to a product in Magento?

谢谢

推荐答案

    $tagName = 'php';
    $customerID = NULL;
    $storeId = Mage::app()->getStore()->getId();
    $productID = 1;

    $tagModel = Mage::getModel('tag/tag');
    $tagModel->loadByName($tagName);
    //$tagModel->unsetData()->loadByName($tagName);  //if using a loop 

    if (!$tagModel->getId()) {
             $tagModel->setName($tagName)
                      ->setFirstCustomerId($customerId)
                      ->setFirstStoreId($storeId)
                      ->setStatus($tagModel->getPendingStatus())
                      ->save();
   }

   $relationStatus = $tagModel->saveRelation($productId, $customerId, $storeId);

这篇关于在Magento中为产品添加标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆