更改Magento产品的属性集。

时间:2013-06-13 12:14:01

标签: magento magento-1.7 magmi

我想更改Magento的属性集。我搜索过,每个人都建议删除该产品并使用新的属性集重新导入它。

我做了同样的事情但是在导入数据后我看不到产品评论和相关的博客文章与产品。

任何人都可以告诉我,在使用新属性集重新导入产品后,是否有可能获得产品评论和相关博客文章。

6 个答案:

答案 0 :(得分:12)

设置后,您无法更改产品的属性集。但是可以使用此模块,因此您无需重新导入数据 https://marketplace.magento.com/flagbit-magento-changeattributeset.html

答案 1 :(得分:5)

也可以直接在数据库中更改属性集。

  • 在表eav_attribute_set
  • 中查找属性集ID
  • 更改catalog_product_entity
  • 中的属性集ID

当然,以这种方式更改数据时要小心。

答案 2 :(得分:2)

做得好而且有点乱:

  • 确保已设置新属性集
  • 导出您要更改的产品
  • 删除您在网站上更改的产品
  • 更改下载文件中的属性集
  • 再次导入已更改的文件
  • 打开每个更改的产品,设置其属性值,保存

或者做我做的事,从Amasty http://amasty.com/mass-product-actions.html安装这个很棒的扩展程序 - 它可以轻松改变,并且可以节省更多时间并增强选项。

答案 3 :(得分:1)

删除产品后,您无法获得旧评价。

您无需删除该产品。您可以通过编辑和使用来更改属性集。 另外明智的是创建一个新的属性集并创建新产品。

答案 4 :(得分:0)

我使用this extension来更改属性集。

我曾经拥有你上面推荐的扩展程序,而且很酷。但前者有更多的功能。

答案 5 :(得分:0)

是。我们可以通过编程方式更改产品属性集。 我更喜欢在目录产品网格中创建massaction以多选产品,然后选择产品的massaction。

在grid.php中创建massaction

$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
                ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
                ->load()
                ->toOptionHash();

$this->getMassactionBlock()->addItem('changeattributeset', array(
                'label'=> Mage::helper('catalog')->__('Change attribute set'),
                'url'  => $block->getUrl('*/*/changeattributeset', array('_current'=>true)),
                'additional' => array(
                    'visibility' => array(
                        'name' => 'attribute_set',
                        'type' => 'select',
                        'class' => 'required-entry',
                        'label' => Mage::helper('catalog')->__('Attribute Set'),
                        'values' => $sets
                    )
                )
            )); 

为所选产品的更改属性集创建控制器操作。

public function changeattributesetAction()
{
    $productIds = $this->getRequest()->getParam('product');
    $storeId = (int)$this->getRequest()->getParam('store', 0);
    if (!is_array($productIds)) {
        $this->_getSession()->addError($this->__('Please select product(s)'));
    } else {
        try {
            foreach ($productIds as $productId) {
                $product = Mage::getSingleton('catalog/product')
                        ->unsetData()
                        ->setStoreId($storeId)
                        ->load($productId)
                        ->setAttributeSetId($this->getRequest()->getParam('attribute_set'))
                        ->setIsMassupdate(true)
                        ->save();
            }
            Mage::dispatchEvent('catalog_product_massupdate_after', array('products'=>$productIds));
            $this->_getSession()->addSuccess(
                    $this->__('Total of %d record(s) were successfully updated', count($productIds))
                );
            }
            catch (Exception $e) {
                $this->_getSession()->addException($e, $e->getMessage());
            }
    }
    $this->_redirect('adminhtml/catalog_product/index/', array());
}