<?php ini_set('display_errors', 1); header('Content-Type: text/html; charset=utf-8'); include 'app/Mage.php'; Mage::app(); //将属性加到所有属性集 //您的属性的code $myAttrCode='width_rate'; $model=Mage::getModel('eav/entity_setup','core_setup'); $attributeId=$model->getAttribute('catalog_product',$myAttrCode); $allAttributeSetIds = $model->getAllAttributeSetIds('catalog_product'); foreach ($allAttributeSetIds as $attributeSetId) { try { $attributeGroupId = $model->getAttributeGroup('catalog_product', $attributeSetId, 'General'); } catch (Exception $e) { echo $e->getMessage(); die('出错'); $attributeGroupId = $model->getDefaultAttributeGroupId('catalog/product', $attributeSetId); } print_r($attributeSetId); print_r($attributeGroupId['attribute_group_id']); print_r($attributeId['attribute_id']); //die(); $model->addAttributeToSet('catalog_product', $attributeSetId, $attributeGroupId['attribute_group_id'], $attributeId['attribute_id']); }
Magento1.9属性加到所有集合(通过脚本方式)
**原创文章未经同意请勿转载**