/** * Remove given attributes if not exist in Magento * * @param array $data * * @return void */ protected function _pruneAttributes(array $data) { $select = $this->_setup->getConnection()->select()->from($this->_setup->getTable('eav/attribute'))->where('is_user_defined = 1'); $magAttributes = $this->_setup->getConnection()->fetchAssoc($select); foreach ($magAttributes as $magAttribute) { $attributeFound = false; while ((list($key, $attribute) = each($data)) && $attributeFound === false) { if ($attribute['attribute_id'] === $magAttribute['attribute_code']) { $attributeFound = true; } } reset($data); if (!$attributeFound) { $this->_setup->removeAttribute($this->_catalogProductEntityTypeId, $magAttribute['attribute_code']); } } }