/** * Create array of attributes for variation * allowed by googleoptimizer config and user defined attributes * * @param Mage_Catalog_Model_Product $product * @return array */ public function getProductAttributes(Varien_Object $product) { /** @var $product Mage_Catalog_Model_Product */ $allowedAttributes = array_keys(Mage::getConfig()->getNode(self::XML_PATH_ALLOWED_ATTRIBUTES)->asArray()); $productAttributes = $product->getAttributes(); $optimizerAttributes = array(); foreach ($productAttributes as $_attributeCode => $_attribute) { if ($_attribute->getIsUserDefined() && $_attribute->getIsVisibleOnFront()) { $optimizerAttributes[] = array('label' => $_attribute->getFrontendLabel(), 'value' => $_attributeCode); } elseif (in_array($_attributeCode, $allowedAttributes)) { $optimizerAttributes[] = array('label' => $_attribute->getFrontendLabel(), 'value' => $_attributeCode); } } return $optimizerAttributes; }
/** * If the customer is not logged in, but we still need to vault, we're going to create a fake customer * * @param $nonce * @param $billingAddress * * @return \Braintree_Customer */ public function storeInGuestVault($nonce, $billingAddress = false) { $guestCustomerCreate = array('id' => $this->getBraintreeId(), 'creditCard' => array('paymentMethodNonce' => $nonce, 'options' => array('verifyCard' => true, 'verificationMerchantAccountId' => $this->getMerchantAccountId()))); // Include billing address information into the customer if ($billingAddress) { // Add in the billing address $guestCustomerCreate['creditCard']['cardholderName'] = $billingAddress['firstName'] . ' ' . $billingAddress['lastName']; $guestCustomerCreate['creditCard']['billingAddress'] = $billingAddress; // Make sure the customer is created with a first name and last name $guestCustomerCreate['firstName'] = $billingAddress['firstName']; $guestCustomerCreate['lastName'] = $billingAddress['lastName']; // Conditionally copy over these fields if (isset($billingAddress['email']) && !empty($billingAddress['email'])) { $guestCustomerCreate['email'] = $billingAddress['email']; } if (isset($billingAddress['company']) && !empty($billingAddress['company'])) { $guestCustomerCreate['company'] = $billingAddress['company']; } if (isset($billingAddress['phone']) && !empty($billingAddress['phone'])) { $guestCustomerCreate['phone'] = $billingAddress['phone']; } } // Dispatch an event to allow modification of the store in vault $object = new Varien_Object(); $object->setAttributes($guestCustomerCreate); Mage::dispatchEvent('gene_braintree_store_in_guest_vault', array('object' => $object)); $guestCustomerCreate = $object->getAttributes(); return Braintree_Customer::create($guestCustomerCreate); }
/** * Return editable values configs * * @param string $type Grid block type * @param string $origin Values origin (if null, all values will be returned) * @return array */ public function getEditableValues($type, $origin = null) { if (!isset($this->_editableValues[$type])) { // Build all base configs $fields = $this->_getEditableFields($type); foreach ($fields as $id => $field) { $fields[$id] = $this->_buildEditableFieldConfig($type, $id, $field); } $attributes = $this->_getEditableAttributes($type); foreach ($attributes as $code => $attribute) { $attributes[$code] = $this->_buildEditableAttributeConfig($type, $code, $attribute); } // Dispatch events for each kind of editable values $fieldsResponse = new Varien_Object(array('fields' => $fields)); $attributesResponse = new Varien_Object(array('attributes' => $attributes)); $attributeFieldsResponse = new Varien_Object(array('attribute_fields' => $this->_getEditableAttributeFields($type))); Mage::dispatchEvent('blcg_grid_type_editable_fields', array('response' => $fieldsResponse, 'type_model' => $this, 'block_type' => $type)); Mage::dispatchEvent('blcg_grid_type_editable_attributes', array('response' => $attributesResponse, 'type_model' => $this, 'block_type' => $type)); Mage::dispatchEvent('blcg_grid_type_editable_attribute_fields', array('response' => $attributeFieldsResponse, 'type_model' => $this, 'block_type' => $type)); // Cache the results $this->_editableValues[$type] = array(self::EDITABLE_TYPE_FIELD => $fieldsResponse->getFields(), self::EDITABLE_TYPE_ATTRIBUTE => $attributesResponse->getAttributes(), self::EDITABLE_TYPE_ATTRIBUTE_FIELD => $attributeFieldsResponse->getAttributeFields()); } if (!is_null($origin)) { if (isset($this->_editableValues[$type][$origin])) { return $this->_editableValues[$type][$origin]; } else { return array(); } } else { return $this->_editableValues[$type]; } }