7
votes

Magento: Supprimer par programme l'attribut de l'attribut-ensemble

J'ai besoin d'une fonction ou d'un code pour supprimer un attribut d'un jeu lorsqu'il est attribué à. Je connais la fonction, pour attribuer un attribut: xxx

ou pour supprimer un attribut: xxx

mais l'attribut ne doit pas être supprimé. Il ne doit plus être possible de voir l'attribut dans le fichier d'attributset 'défaut' (groupe 'General').

Je ne trouve aucune fonction comme: xxx

ou qc. comme ça


0 commentaires

4 Réponses :


9
votes

Vous pouvez essayer ce code dans votre script de configuration xxx


0 commentaires

0
votes

Ceci est maintenant le code complet que j'utilise et ce qui fonctionne:

$installer = $this;
$installer->startSetup();

$attributeType = 'catalog_product';

$attribute_set_name = 'Default';

$attributeCode='my_attribute';

$setId = $installer->getAttributeSetId('catalog_product', $attribute_set_name);

$attributeId=$installer->getAttributeId($attributeType, $attributeCode);

$installer->deleteTableRow('eav/entity_attribute', 'attribute_id', $attributeId, 'attribute_set_id', $setId);

$installer->endSetup();


0 commentaires

0
votes

// Il supprimera définitivement votre attribut.

$Attributes = array('accessories_size','accessories_type','apparel_type','author_artist','bag_luggage_type','bedding_pattern','bed_bath_type','books_music_type','camera_megapixels',
'camera_type','coater','color','colors','cost','decor_type','ebizmarts_mark_visited','electronic_type','featured','fit','format','frame_style','gender','gendered','genre','homeware_style',
'home_decor_type','impressions','is_sold','jewelry_type','length','lens_type','luggage_size','luggage_style','luggage_travel_style','make','manufacturer','material','model','necklace_length',
'occasion','perfector','sample_item_1','sheet_size','shoe_size','shoe_type','size','sleeve_length','style');

$entityType = 'catalog_product';

foreach($Attributes as $index => $attrCode){

        $attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode($entityType,$attrCode);   // it return false when attribute not exist.

        if($attributeId){
            Mage::getModel('catalog/product_attribute_api')->remove($attributeId);          
        }
}


0 commentaires

1
votes

ci-dessous supprimera l'attribut de Attributeet xxx


0 commentaires