/** * Lock the attributes of a product/category so that it can not be overwritten using Magento's backend. * @param Mage_Catalog_Model_Abstract $model */ protected function _lockAttributes(Mage_Catalog_Model_Abstract $model) { // Is product assigned to import profile. if (!($profiles = $model->getData('ho_import_profile'))) { return; } foreach ($profiles as $profileData) { $profile = $profileData['profile']; // Is lock attributes functionality enabled. $lockAttributes = sprintf('global/ho_import/%s/import_options/lock_attributes', $profile); $fieldMapNode = Mage::getConfig()->getNode($lockAttributes); if (!$fieldMapNode || !$fieldMapNode->asArray()) { continue; } // Get the mapper. /** @var Ho_Import_Model_Mapper $mapper */ $mapper = Mage::getModel('ho_import/mapper'); $mapper->setProfileName($profile); $storeCode = $model->getStore()->getCode(); // Check if attributes need to be locked. $attributes = $model->getAttributes(); foreach ($attributes as $attribute) { /** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */ $mapper->setStoreCode($attribute->isScopeStore() || $attribute->isScopeWebsite() ? $storeCode : 'admin'); $fieldConfig = $mapper->getFieldConfig($attribute->getAttributeCode()); if (isset($fieldConfig['@'])) { $this->_lockAttribute($attribute, $model, $profile); } } } }