/** * Cycle through attributes and validate against Bronto Field type * * @param Bronto_Api_Contact_Row $brontoContact * @param $source * @param $attributes * @param Mage_Core_Model_Store $store * @param string $type 'customer' or 'address' * * @return Bronto_Api_Contact_Row */ protected function _processAttributes(Bronto_Api_Contact_Row $brontoContact, $source, $attributes, Mage_Core_Model_Store $store, $type = 'customer') { $helper = Mage::helper('bronto_customer'); // For each Customer attribute foreach ($attributes as $attribute) { if ('' == $attribute->getFrontendLabel()) { continue; } $_attributeCode = $attribute->getAttributeCode(); // Get Attribute Field switch ($type) { case 'billing_address': case 'address': $_fieldName = $helper->getPrefixedAttributeField($_attributeCode, $type, 'store', $store->getId()); // Backward compatibility for country name and codes if (array_key_exists($_attributeCode, $this->_expandedfields)) { list($method, $label, $field) = $this->_expandedfields[$_attributeCode]; $_attributeValue = strtolower($source->{$method}()); $_brontoField = $helper->getPrefixedAttributeField($field, $type, 'store', $store->getId()); if (!$this->_skippableProcessValue($_brontoField, $_attributeValue)) { $brontoContact->setField($_brontoField, $_attributeValue); } } break; default: $_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField($_attributeCode, 'store', $store->getId()); break; } // Get Customer Attribute Value $_attributeValue = $this->_getReadableValue($attribute, $source->getData($_attributeCode)); // Skip un-mapped or empty attributes if ($this->_skippableProcessValue($_fieldName, $_attributeValue)) { continue; } $brontoContact->setField($_fieldName, $_attributeValue); } return $brontoContact; }
/** * Cycle through attributes and validate against Bronto Field type * * @param Bronto_Api_Contact_Row $brontoContact * @param $source * @param $attributes * @param Mage_Core_Model_Store $store * @param string $type 'customer' or 'address' * * @return Bronto_Api_Contact_Row */ protected function _processAttributes(Bronto_Api_Contact_Row $brontoContact, $source, $attributes, Mage_Core_Model_Store $store, $type = 'customer') { // For each Customer attribute foreach ($attributes as $attribute) { if ('' == $attribute->getFrontendLabel()) { continue; } $_attributeCode = $attribute->getAttributeCode(); // Get Attribute Field switch ($type) { case 'address': $_fieldName = Mage::helper('bronto_customer')->getAddressAttributeField($_attributeCode, 'store', $store->getId()); break; default: $_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField($_attributeCode, 'store', $store->getId()); break; } // Get Customer Attribute Value $_attributeValue = $this->_getReadableValue($attribute, $source->getData($_attributeCode)); // Skip un-mapped or empty attributes if (empty($_fieldName) || '_none_' == $_fieldName || !$_attributeValue || '' == $_attributeValue) { continue; } // Store Bronto Key => Magento field label for errors if (!array_key_exists($_fieldName, $this->_fieldMap)) { $this->_fieldMap[$_fieldName] = $attribute->getFrontendLabel(); } $brontoContact->setField($_fieldName, $_attributeValue); } return $brontoContact; }