Skip to content

Instantly share code, notes, and snippets.

@aurire
aurire / gist:1827ed6da6e46ef33a11dcf16afa2afd
Created April 16, 2016 18:30
Magento. Remove attribute
//Remove attribute
Mage::getModel('catalog/product_attribute_api')->remove('test_01');
//Remove just from attribute set
Mage::getModel('catalog/product_attribute_set_api')
->attributeRemove($attributeId, $attributeSetId);
@aurire
aurire / gist:c81d212bd5e243d7211c4df309ccf710
Created April 16, 2016 18:24
Magento. Delete attribute set by attribute set name
$entityTypeId = Mage::getModel('eav/entity')
->setType('catalog_product')
->getTypeId();
$attributeSetName = 'My New Set';
$attributeSetId = Mage::getModel('eav/entity_attribute_set')
->getCollection()
->setEntityTypeFilter($entityTypeId)
->addFieldToFilter('attribute_set_name', $attributeSetName)
->getFirstItem()
->getAttributeSetId();
@aurire
aurire / get_attribute_set_id.php
Last active December 17, 2019 11:14
Magento. Get Catalog Product Entity Type ID, instead of using 4 (MAGIC NUMBER). Works the same, for getting other entity type id by name.
$entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
//Alternative
$entityTypeId = Mage::getSingleton('ceav/config')->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getId();
@aurire
aurire / 0_reuse_code.js
Created January 13, 2016 14:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console