本文整理汇总了PHP中Varien_Object::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::toArray方法的具体用法?PHP Varien_Object::toArray怎么用?PHP Varien_Object::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toArray
/**
* Public wrapper for __toArray
*
* @param array $arrAttributes
* @return array
*/
public function toArray(array $arrAttributes = array())
{
$this->setStreet1($this->getStreet(1));
$this->setStreet2($this->getStreet(2));
$this->setStreet($this->getStreet(1) . "\n" . $this->getStreet(2));
return parent::toArray($arrAttributes);
}
示例2: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$blockData = Mage::registry(AW_Autorelated_Adminhtml_ShoppingcartblockController::BLOCK_REGISTRY_KEY);
if (!$blockData instanceof Varien_Object) {
$blockData = new Varien_Object();
}
$fieldset = $form->addFieldset('general', array('legend' => $this->__('General')));
$fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'required' => true));
if ($blockData->getData('status') === null) {
$blockData->setData('status', 1);
}
$fieldset->addField('status', 'select', array('name' => 'status', 'label' => $this->__('Status'), 'required' => true, 'values' => Mage::getModel('awautorelated/source_status')->toOptionArray()));
if (!Mage::app()->isSingleStoreMode()) {
$fieldset->addField('store', 'multiselect', array('name' => 'store[]', 'label' => $this->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
} else {
$blockData->setStore(Mage::app()->getStore(true)->getId());
$fieldset->addField('store', 'hidden', array('name' => 'store[]'));
}
if ($blockData->getData('customer_groups') === null) {
$blockData->setData('customer_groups', array(Mage_Customer_Model_Group::CUST_GROUP_ALL));
}
$fieldset->addField('customer_groups', 'multiselect', array('name' => 'customer_groups[]', 'label' => $this->__('Customer groups'), 'title' => $this->__('Customer groups'), 'required' => true, 'values' => Mage::getModel('awautorelated/source_customer_groups')->toOptionArray()));
$fieldset->addField('priority', 'text', array('name' => 'priority', 'label' => $this->__('Priority'), 'title' => $this->__('Priority'), 'required' => false));
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$fieldset->addField('date_from', 'date', array('name' => 'date_from', 'label' => $this->__('Date From'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
$fieldset->addField('date_to', 'date', array('name' => 'date_to', 'label' => $this->__('Date To'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
$positionSourceModel = Mage::getModel('awautorelated/source_position');
$fieldset->addField('position', 'select', array('name' => 'position', 'label' => $this->__('Position'), 'title' => $this->__('Position'), 'required' => true, 'values' => $positionSourceModel->toOptionArray(AW_Autorelated_Model_Source_Type::SHOPPING_CART_BLOCK)));
$form->setValues($blockData->toArray());
$this->setForm($form);
}
示例3: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$html = $this->_getHeaderHtml($element);
$modules = array_keys((array) Mage::getConfig()->getNode('modules')->children());
$dispatchResult = new Varien_Object($modules);
Mage::dispatchEvent('magetrashapp_system_config_magetrashapp_manage_extns_render_before', array('modules' => $dispatchResult));
$modules = $dispatchResult->toArray();
sort($modules);
foreach ($modules as $moduleName) {
if ($moduleName === 'Mage_Adminhtml' || $moduleName === 'Hackathon_MageTrashApp' || stripos($moduleName, 'Mage_') !== false) {
continue;
}
$resName = Mage::helper('magetrashapp')->getResourceName($moduleName);
if ($resName === null) {
continue;
}
$number = Mage::getResourceSingleton('core/resource')->getDbVersion($resName);
if (!$resName || $resName == $number) {
continue;
}
$html .= $this->_getFieldHtml($element, $moduleName);
}
$html .= $this->_getFooterHtml($element);
return $html;
}
示例4: testToArray
/**
* Tests Varien_Object->toArray()
*/
public function testToArray()
{
$this->assertEquals(array(), $this->_object->toArray());
$this->assertEquals(array('key' => null), $this->_object->toArray(array('key')));
$this->_object->setData(array('key1' => 'value1', 'key2' => 'value2'));
$this->assertEquals(array('key1' => 'value1'), $this->_object->toArray(array('key1')));
$this->assertEquals(array('key2' => 'value2'), $this->_object->__toArray(array('key2')));
}
示例5: updateWall
public function updateWall($observer)
{
if (Mage::helper('fbintegrator')->extEnabled() && Mage::helper('fbintegrator')->getWallEnabled()) {
$order = $observer->getEvent()->getOrder();
if (Mage::helper('fbintegrator')->isRegisteredOrder($order->getId())) {
return;
} else {
Mage::helper('fbintegrator')->registerOrder($order->getId());
}
$facebook = new AW_FBIntegrator_Model_Facebook_Api(Mage::helper('fbintegrator')->getAppConfig());
$session = $facebook->getUser();
if ($session) {
try {
$orderItems = $order->getAllVisibleItems();
$store = Mage::app()->getStore();
$urlConfig = array('_secure' => Mage::helper('fbintegrator')->isSecure(), '_use_rewrite' => Mage::helper('fbintegrator')->useRewrite(), '_store_to_url' => Mage::helper('fbintegrator')->addCode());
$storeLink = Mage::getUrl('', $urlConfig);
$message = Mage::helper('fbintegrator')->getWallMessage();
$messageParams = array('count' => array('template' => '{items_count}', 'real' => count($order->getAllVisibleItems())), 'link' => array('template' => '{store_link}', 'real' => $storeLink));
foreach ($messageParams as $param) {
$message = str_replace($param['template'], $param['real'], $message);
}
$description = array();
$media = array();
$countToPost = Mage::helper('fbintegrator')->getWallCount();
$count = (int) $countToPost ? min((int) $countToPost, count($orderItems)) : count($orderItems);
for ($i = 0; $i < $count; $i++) {
$product = $orderItems[$i];
$productLink = Mage::helper('fbintegrator')->useRewrite() ? Mage::helper('fbintegrator')->getProductRewriteUrl($product->getProductId()) : 'catalog/product/view/id/' . $product->getProductId();
$productInfo = array('count' => array('template' => '{items_count}', 'real' => $product->getQtyOrdered()), 'name' => array('template' => '{item_name}', 'real' => $product->getName()), 'price' => array('template' => '{item_price}', 'real' => $store->convertPrice($product->getBasePrice(), true, false)), 'link' => array('template' => '{item_link}', 'real' => $storeLink . $productLink), 'store' => array('template' => '{store_link}', 'real' => $storeLink));
$row = Mage::helper('fbintegrator')->getWallTemplate();
foreach ($productInfo as $param) {
$row = str_replace($param['template'], $param['real'], $row);
}
$description[] = $row;
$description[] = '<center></center>';
//facebook line break
if (Mage::helper('fbintegrator')->postImagesToWall()) {
$media[] = array('type' => 'image', 'src' => Mage::getModel('catalog/product')->load($product->getProductId())->getImageUrl(), 'href' => $storeLink . $productLink);
}
}
$param = array('method' => 'stream.publish', 'message' => $message, 'attachment' => array('description' => implode(' ', $description), 'media' => $media));
$params = new Varien_Object($param);
Mage::dispatchEvent('aw_fbintegrator_order_wall_post_before', array('params' => $params, 'observer' => $observer));
$param = $params->toArray();
$facebook->api($param);
} catch (Exception $e) {
// Mage::log($e->getMessage());
}
}
}
}
示例6: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$blockData = Mage::registry(AW_Autorelated_Adminhtml_ShoppingcartblockController::BLOCK_REGISTRY_KEY);
if (!$blockData instanceof Varien_Object) {
$blockData = new Varien_Object();
}
$fieldset = $form->addFieldset('general', array('legend' => $this->__('General')));
$generalOptions = array();
if ($relatedProducts = $blockData->getData('related_products')) {
if ($relatedProducts->getData('options')) {
$generalOptions = $relatedProducts->getData('options');
}
$blockData->setData('related_products_count', $relatedProducts->getData('count'));
$blockData->setData('show_out_of_stock', $relatedProducts->getData('show_out_of_stock'));
$order = $relatedProducts->getData('order');
if (!is_array($order)) {
$order = array();
}
$blockData->setData('order', isset($order['type']) ? $order['type'] : null);
$blockData->setData('order_attribute', isset($order['attribute']) ? $order['attribute'] : null);
$blockData->setData('order_direction', isset($order['direction']) ? $order['direction'] : null);
}
$optionsRenderer = $this->getLayout()->createBlock('awautorelated/adminhtml_blocks_shoppingcart_edit_tabs_relatedproducts_attributes')->setValues($generalOptions);
$fieldset->addField('general_options', 'text', array('label' => $this->__('Attributes'), 'name' => 'related_products[options]'))->setRenderer($optionsRenderer);
$conditionsRenderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')->setTemplate('promo/fieldset.phtml')->setNewChildUrl($this->getUrl('*/*/newConditionHtml', array('form' => 'related_conditions_fieldset', 'prefix' => 'related', 'rule' => base64_encode('awautorelated/blocks_shoppingcart_rulerelated'))));
$fieldset = $form->addFieldset('related_conditions_fieldset', array('legend' => $this->__('Conditions (leave blank for all products)')))->setRenderer($conditionsRenderer);
/** @var $model AW_Autorelated_Model_Blocks_Shoppingcart_Ruleviewed */
$model = Mage::getModel('awautorelated/blocks_shoppingcart_rulerelated');
$model->setForm($fieldset);
$model->getConditions()->setJsFormObject('related_conditions');
if ($relatedProducts && is_array($conditions = $relatedProducts->getData('conditions'))) {
$model->getConditions()->loadArray($conditions, 'related');
$model->getConditions()->setJsFormObject('related_conditions');
}
$fieldset->addField('related_conditions', 'text', array('name' => 'related_conditions', 'label' => Mage::helper('salesrule')->__('Conditions'), 'title' => Mage::helper('salesrule')->__('Conditions')))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/conditions'));
$fieldset = $form->addFieldset('other', array('legend' => $this->__('Other')));
if ($blockData->getData('related_products_count') === null) {
$blockData->setData('related_products_count', Mage::helper('awautorelated/config')->getNumberOfProducts());
}
$fieldset->addField('related_products_count', 'text', array('name' => 'related_products[count]', 'title' => $this->__('Number of products'), 'label' => $this->__('Number of products'), 'required' => true));
$fieldset->addField('order', 'select', array('name' => 'related_products[order][type]', 'label' => $this->__('Order Products'), 'title' => $this->__('Order Products'), 'values' => Mage::getModel('awautorelated/source_block_common_order')->toOptionArray()));
$fieldset->addField('order_attribute', 'select', array('name' => 'related_products[order][attribute]', 'values' => Mage::getModel('awautorelated/source_catalog_product_attributes')->toOptionArray(), 'note' => $this->__('Select Attribute')));
$fieldset->addField('order_direction', 'select', array('name' => 'related_products[order][direction]', 'values' => Mage::getModel('awautorelated/source_resource_collection_order')->toOptionArray(), 'note' => $this->__('Sort Direction')));
$fieldset->addField('show_out_of_stock', 'select', array('name' => 'related_products[show_out_of_stock]', 'label' => $this->__('Show "Out of stock" Products'), 'title' => $this->__('Show "Out of stock" Products'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()));
$form->setValues($blockData->toArray());
$this->setForm($form);
}
示例7: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$html = $this->_getHeaderHtml($element);
$modules = array_keys((array) Mage::getConfig()->getNode('modules')->children());
$dispatchResult = new Varien_Object($modules);
Mage::dispatchEvent('adminhtml_system_config_advanced_disableoutput_render_before', array('modules' => $dispatchResult));
$modules = $dispatchResult->toArray();
sort($modules);
foreach ($modules as $moduleName) {
if ($moduleName === 'Mage_Adminhtml') {
continue;
}
$html .= $this->_getFieldHtml($element, $moduleName);
}
$html .= $this->_getFooterHtml($element);
return $html;
}
示例8: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$html = $this->_getHeaderHtml($element);
$modules = array_keys((array) Mage::getConfig()->getNode('modules')->children());
$dispatchResult = new Varien_Object($modules);
Mage::dispatchEvent('magetrashapp_system_config_magetrashapp_manage_extns_render_before', array('modules' => $dispatchResult));
$modules = $dispatchResult->toArray();
sort($modules);
foreach ($modules as $moduleName) {
$moduleStatus = Mage::getConfig()->getModuleConfig($moduleName)->is('active', 'true');
if ($moduleName === 'Mage_Adminhtml' || $moduleName === 'Hackathon_MageTrashApp' || stripos($moduleName, 'Mage_') !== false) {
continue;
}
$html .= $this->_getFieldHtml($element, $moduleName, $moduleStatus);
}
$html .= $this->_getFooterHtml($element);
return $html;
}
示例9: saveConfig
public function saveConfig($observer)
{
$modules = array_keys((array) Mage::getConfig()->getNode('modules')->children());
$dispatchResult = new Varien_Object($modules);
$modules = $dispatchResult->toArray();
foreach ($modules as $moduleName) {
if ($moduleName === 'Mage_Adminhtml' || $moduleName === 'Hackathon_MageTrashApp' || stripos($moduleName, 'Mage_') !== false) {
continue;
}
$configFlag = Mage::getStoreConfig('magetrashapp/manage_extns/' . $moduleName);
switch ($configFlag) {
case Hackathon_MageTrashApp_Helper_Data::ENABLE:
Mage::helper('magetrashapp')->activateModule($moduleName);
break;
case Hackathon_MageTrashApp_Helper_Data::DISABLE:
$this->disableModules[] = $moduleName;
Mage::helper('magetrashapp')->activateModule($moduleName, false);
break;
case Hackathon_MageTrashApp_Helper_Data::UNINSTALL:
Mage::helper('magetrashapp')->uninstallModule($moduleName);
break;
default:
break;
}
$configFlag = Mage::getStoreConfig('magetrashapp/rewind_extns/' . $moduleName);
if ($configFlag != 0) {
$version = substr($configFlag, 2);
$configFlag = $configFlag[0];
} elseif (is_null($configFlag)) {
continue;
}
switch ($configFlag) {
case Hackathon_MageTrashApp_Helper_Data::DELETE:
Mage::helper('magetrashapp')->deleteCoreResource($moduleName);
break;
case Hackathon_MageTrashApp_Helper_Data::REWIND:
Mage::helper('magetrashapp')->rewindCoreResource($moduleName, $version);
break;
default:
break;
}
}
}
示例10: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$blockData = Mage::registry(AW_Autorelated_Adminhtml_ShoppingcartblockController::BLOCK_REGISTRY_KEY);
if (!$blockData instanceof Varien_Object) {
$blockData = new Varien_Object();
}
$renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')->setTemplate('promo/fieldset.phtml')->setNewChildUrl($this->getUrl('*/*/newConditionHtml', array('form' => 'order_conditions_fieldset', 'prefix' => 'viewed', 'rule' => base64_encode('awautorelated/blocks_shoppingcart_ruleviewed'))));
$fieldset = $form->addFieldset('order_conditions_fieldset', array('legend' => Mage::helper('salesrule')->__('Apply the rule only if the following conditions are met (leave blank for all products)')))->setRenderer($renderer);
/** @var $model AW_Autorelated_Model_Blocks_Shoppingcart_Ruleviewed */
$model = Mage::getModel('awautorelated/blocks_shoppingcart_ruleviewed');
$model->setForm($fieldset);
$model->getConditions()->setJsFormObject('order_conditions_fieldset');
if ($blockData->getData('currently_viewed') && is_array($conditions = $blockData->getData('currently_viewed')->getData('conditions'))) {
$model->getConditions()->loadArray($conditions, 'viewed');
$model->getConditions()->setJsFormObject('order_conditions_fieldset');
}
$fieldset->addField('order_conditions', 'text', array('name' => 'order_conditions', 'label' => Mage::helper('salesrule')->__('Conditions'), 'title' => Mage::helper('salesrule')->__('Conditions')))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/conditions'));
$form->setValues($blockData->toArray());
$this->setForm($form);
}
示例11: getMergeVars
/**
* Return Merge Fields mapped to Magento attributes
*
* @param object $customer
* @param bool $includeEmail
* @param integer $websiteId
* @return array
*/
public function getMergeVars($customer, $includeEmail = FALSE, $websiteId = NULL)
{
$merge_vars = array();
$maps = $this->getMergeMaps($customer->getStoreId());
if (!$maps) {
return;
}
$request = Mage::app()->getRequest();
//Add Customer data to Subscriber if is Newsletter_Subscriber is Customer
if (!$customer->getDefaultShipping() && $customer->getEntityId()) {
$customer->addData(Mage::getModel('customer/customer')->load($customer->getEntityId())->setStoreId($customer->getStoreId())->toArray());
}
foreach ($maps as $map) {
$customAtt = $map['magento'];
$chimpTag = $map['mailchimp'];
if ($chimpTag && $customAtt) {
$key = strtoupper($chimpTag);
switch ($customAtt) {
case 'gender':
$val = (int) $customer->getData(strtolower($customAtt));
if ($val == 1) {
$merge_vars[$key] = 'Male';
} elseif ($val == 2) {
$merge_vars[$key] = 'Female';
}
break;
case 'dob':
$dob = (string) $customer->getData(strtolower($customAtt));
if ($dob) {
$merge_vars[$key] = substr($dob, 5, 2) . '/' . substr($dob, 8, 2);
}
break;
case 'billing_address':
case 'shipping_address':
$addr = explode('_', $customAtt);
$address = $customer->{'getPrimary' . ucfirst($addr[0]) . 'Address'}();
if ($address) {
$merge_vars[$key] = array('addr1' => $address->getStreet(1), 'addr2' => $address->getStreet(2), 'city' => $address->getCity(), 'state' => !$address->getRegion() ? $address->getCity() : $address->getRegion(), 'zip' => $address->getPostcode(), 'country' => $address->getCountryId());
$telephone = $address->getTelephone();
if ($telephone) {
$merge_vars['TELEPHONE'] = $telephone;
}
$company = $address->getCompany();
if ($company) {
$merge_vars['COMPANY'] = $company;
}
}
break;
case 'date_of_purchase':
$last_order = Mage::getResourceModel('sales/order_collection')->addFieldToFilter('customer_email', $customer->getEmail())->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))->setOrder('created_at', 'desc')->getFirstItem();
if ($last_order->getId()) {
$merge_vars[$key] = Mage::helper('core')->formatDate($last_order->getCreatedAt());
}
break;
case 'ee_customer_balance':
$merge_vars[$key] = '';
if ($this->isEnterprise() && $customer->getId()) {
$_customer = Mage::getModel('customer/customer')->load($customer->getId());
if ($_customer->getId()) {
if (Mage::app()->getStore()->isAdmin()) {
$websiteId = is_null($websiteId) ? Mage::app()->getStore()->getWebsiteId() : $websiteId;
}
$balance = Mage::getModel('enterprise_customerbalance/balance')->setWebsiteId($websiteId)->setCustomerId($_customer->getId())->loadByCustomer();
$merge_vars[$key] = $balance->getAmount();
}
}
break;
case 'group_id':
$group_id = (int) $customer->getData(strtolower($customAtt));
$customerGroup = Mage::helper('customer')->getGroups()->toOptionHash();
if ($group_id == 0) {
$merge_vars[$key] = 'NOT LOGGED IN';
} else {
$merge_vars[$key] = $customerGroup[$group_id];
}
break;
default:
if ($value = (string) $customer->getData(strtolower($customAtt)) or $value = (string) $request->getPost(strtolower($customAtt))) {
$merge_vars[$key] = $value;
}
break;
}
}
}
//GUEST
if (!$customer->getId() && (!$request->getPost('firstname') || !$request->getPost('lastname'))) {
$guestFirstName = $this->config('guest_name', $customer->getStoreId());
$guestLastName = $this->config('guest_lastname', $customer->getStoreId());
if ($guestFirstName) {
$merge_vars['FNAME'] = $guestFirstName;
}
if ($guestLastName) {
//.........这里部分代码省略.........
示例12: getCheckoutFormFields
//.........这里部分代码省略.........
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
if (!$order || !$order->getId()) {
throw new Mage_Payment_Exception('Cannot load order with increment id "' . $orderIncrementId . '"');
}
$language = Mage::getStoreConfig('general/locale/code') ?: 'en_GB';
$totalAmount = $this->formatAmount($order->getGrandTotal(), $order->getOrderCurrencyCode());
$fields = new Varien_Object();
$fields->setMerchant($this->getConfigData('merchant_id'))->setCurrency($this->getDibsCurrencyCode($order->getOrderCurrencyCode()))->setAmount($totalAmount)->setLanguage($language)->setData('orderId', $order->getIncrementId())->setData('acceptReturnUrl', $this->getReturnUrl())->setData('cancelReturnUrl', $this->getCancelUrl())->setData('callbackUrl', $this->getCallbackUrl());
if (trim($this->getConfigData('payment_type')) !== '') {
$fields->setData('payType', $this->getConfigData('payment_type'));
}
if ($this->getConfigData('test')) {
$fields->setTest('1');
}
if ($this->getConfigData('payment_action') === Mage_Paygate_Model_Authorizenet::ACTION_AUTHORIZE_CAPTURE) {
$fields->setData('capturenow', '1');
}
$billingAddress = $order->getBillingAddress();
$fields->setData('billingFirstName', $this->_cleanDibsValue($billingAddress->getFirstname()));
$fields->setData('billingLastName', $this->_cleanDibsValue($billingAddress->getLastname()));
$fields->setData('billingAddress', $this->_cleanDibsValue($billingAddress->getStreet(1)));
$street2 = $billingAddress->getStreet(2);
if (!empty($street2)) {
$fields->setData('billingAddress2', $this->_cleanDibsValue($street2));
}
$email = $order->getCustomerEmail() ?: $billingAddress->getEmail();
$fields->setData('billingPostalCode', $this->_cleanDibsValue($billingAddress->getPostcode()));
$fields->setData('billingPostalPlace', $this->_cleanDibsValue($billingAddress->getCity()));
$fields->setData('billingEmail', $email);
$fields->setData('billingMobile', $this->_cleanDibsValue($order->getTelephone()));
$oiData = array();
$calculatedAmount = 0;
$i = 1;
foreach ($order->getAllItems() as $item) {
if ($item->getParentItemId()) {
// Only pass main products
continue;
}
$name = $item->getName();
if (empty($name)) {
// Gift wraps etc don't have names (what else do they have?) DIBS needs the name.
$name = $item->getSku();
}
$name = $this->_cleanDibsValue($name);
$sku = $this->_cleanDibsValue($item->getSku());
$amount = $this->formatAmount($item->getPriceInclTax(), $order->getOrderCurrencyCode());
$row = (int) $item->getQtyOrdered() . ';' . $name . ';' . $amount . ';' . $sku;
$oiData['oiRow' . $i++] = $row;
$calculatedAmount += bcmul($amount, $item->getQtyOrdered());
}
// Shipping, giftcards and discounts needs to be separate rows, use the
// quote totals to determine what to print and exclude values that
// are already included from other places
$quoteId = $order->getQuoteId();
$quote = Mage::getModel('sales/quote')->load($quoteId);
$quote->collectTotals();
$totalsToExclude = array('grand_total', 'subtotal', 'tax', 'klarna_tax');
foreach ($quote->getTotals() as $code => $total) {
if (in_array($code, $totalsToExclude)) {
continue;
}
switch ($code) {
case 'giftcardaccount':
case 'giftwrapping':
case 'discount':
case 'ugiftcert':
$value = -abs($total->getValue());
if (empty($value)) {
continue 2;
}
break;
case 'shipping':
// We have to somehow make sure that we use the correctly
// calculated value, we can't rely on the shipping tax
// being part of the quote totals
$value = $order->getShippingTaxAmount() + $order->getShippingAmount();
break;
default:
$value = $total->getValue();
}
$title = $total->getTitle();
if (empty($title)) {
$title = $code;
}
$amount = $this->formatAmount($value, $order->getOrderCurrencyCode());
$row = '1;' . $title . ';' . $amount . ';' . $code;
$oiData['oiRow' . $i++] = $row;
$calculatedAmount += $amount;
}
if ($totalAmount === $calculatedAmount) {
$fields->setData('oiTypes', 'QUANTITY;DESCRIPTION;AMOUNT;ITEMID');
$fields->setData('oiNames', 'Quantity;Product;Amount;SKU');
foreach ($oiData as $key => $value) {
$fields->setData($key, $value);
}
}
$hmac = $this->calculateMac($fields->toArray());
$fields->setData('MAC', $hmac);
return $fields;
}
示例13: capture
/**
* Capture
*
* @param Varien_Object $orderPayment
* @param float $amount
* @return Mage_Payment_Model_Abstract
*/
public function capture(Varien_Object $payment, $amount)
{
$log = Mage::getModel('allpago_mc/log');
$gwap = Mage::getModel('gwap/order')->load($payment->getOrder()->getId(), 'order_id');
if ($gwap->getStatus() != Allpago_Gwap_Model_Order::STATUS_CAPTURED) {
// Processamento de pedidos não novos
if ($gwap->getStatus() == Allpago_Gwap_Model_Order::STATUS_CREATED) {
$this->authorize($payment, $amount);
/**
* reload item
*/
$gwap->clearInstance();
$gwap = Mage::getModel('gwap/order')->load($payment->getOrder()->getId(), 'order_id');
$gwap->setStatus(Allpago_Gwap_Model_Order::STATUS_CAPTUREPAYMENT);
$gwap->save();
}
$url = Mage::helper('gwap')->getRequestURL();
if ($this->_cc) {
$cc1 = new Varien_Object(unserialize(Mage::helper('core')->decrypt($this->_cc)));
$cc2 = new Varien_Object(unserialize(Mage::helper('core')->decrypt($this->_cc2)));
} else {
$cc1 = new Varien_Object(unserialize(Mage::helper('core')->decrypt($gwap->getInfo())));
$cc2 = new Varien_Object(unserialize(Mage::helper('core')->decrypt($gwap->getInfo2())));
}
$parameters1 = $cc1->toArray();
$parameters2 = $cc2->toArray();
$postString1 = Mage::helper('gwap')->buildPostString($parameters1);
$postString2 = Mage::helper('gwap')->buildPostString($parameters2);
$response1 = Mage::helper('gwap')->makeCurlRequest($url, $postString1);
$response2 = Mage::helper('gwap')->makeCurlRequest($url, $postString2);
$resultCode1 = explode('.', $response1['PROCESSING.CODE']);
$resultCode1 = $resultCode1[2];
$resultCode2 = explode('.', $response2['PROCESSING.CODE']);
$resultCode2 = $resultCode2[2];
if ($resultCode1 != '90') {
$errorMsg = $gwap->getCcType() . ': Payment code: ' . $response1['PAYMENT.CODE'] . ' (' . $response1['PROCESSING.REASON'] . ' - ' . $response1['PROCESSING.RETURN'] . ')';
//Captura manual ativada
if (Mage::getStoreConfig('payment/gwap_cc/captura')) {
$log->add($gwap->getOrderId(), 'Payment', 'capture()', Allpago_Mc_Model_Mc::STATUS_ERROR, 'Ocorreu um erro', $errorMsg);
}
Mage::throwException($errorMsg);
}
if ($resultCode2 != '90') {
$errorMsg = $gwap->getCcType2() . ': Payment code: ' . $response2['PAYMENT.CODE'] . ' (' . $response2['PROCESSING.REASON'] . ' - ' . $response2['PROCESSING.RETURN'] . ')';
//Captura manual ativada
if (Mage::getStoreConfig('payment/gwap_cc/captura')) {
$log->add($gwap->getOrderId(), 'Payment', 'capture()', Allpago_Mc_Model_Mc::STATUS_ERROR, 'Ocorreu um erro', $errorMsg);
}
// Em caso de erro, estornar primeiro cartão
$removeResult = $this->removeCreditAuto($payment->getOrder(), $parameters1['PRESENTATION.AMOUNT'], $response1['IDENTIFICATION.UNIQUEID'], $gwap->getCcType(), 1);
Mage::throwException($errorMsg . '<br/>' . $gwap->getCcType() . ': ' . $removeResult);
}
$log->add($gwap->getOrderId(), 'Payment', 'capture()', Allpago_Mc_Model_Mc::STATUS_CAPTURED, 'Pagamento capturado');
//Salva UNIQUEID da captura para possibilitar estorno
$gwap->setInfo(serialize(array('UNIQUEID' => $response1['IDENTIFICATION.UNIQUEID'])));
$gwap->setInfo2(serialize(array('UNIQUEID' => $response2['IDENTIFICATION.UNIQUEID'])));
$gwap->setCaptureResult(serialize($this->getTID($resultCode1)));
$gwap->setCaptureResult2(serialize($this->getTID2($resultCode2)));
//Completar processo do pedido para o caso do RG gerar erro.
$gwap->setStatus(Allpago_Gwap_Model_Order::STATUS_CAPTURED);
$gwap->setErrorCode(null);
$gwap->setErrorMessage(null);
$gwap->setTries(0);
$gwap->setAbandoned(0);
$gwap->save();
}
return $this;
}
示例14: aggregate
/**
* Aggregate data for this tracker
*
* @param string $incremental
* @param Mzax_Emarketing_Model_Campaign $campaign
* @return Mzax_Emarketing_Model_Conversion_Tracker
*/
public function aggregate($incremental = null, Mzax_Emarketing_Model_Campaign $campaign = null)
{
$options = new Varien_Object(array('aggregator' => array('goals', 'tracker', 'dimension'), 'tracker_id' => $this->getId(), 'verbose' => false));
Mage::dispatchEvent($this->_eventPrefix . '_aggregate', array('options' => $options, 'campaign' => $campaign, 'tracker' => $this));
if ($incremental) {
$options->setIncremental((int) $incremental);
}
if ($campaign) {
if ($campaign instanceof Mzax_Emarketing_Model_Campaign) {
$campaign = $campaign->getId();
}
$options->setCampaignId((int) $campaign);
}
/* @var $report Mzax_Emarketing_Model_Report */
$report = Mage::getSingleton('mzax_emarketing/report');
$report->aggregate($options->toArray());
return $this;
}
示例15: validateAction
/**
* validate module before saving
* @access public
* @return void
* @author Marius Strajeru <marius.strajeru@gmail.com>
*/
public function validateAction()
{
$errors = array();
$response = new Varien_Object();
$response->setError(false);
$data = $this->getRequest()->getPost();
$entities = $this->getRequest()->getPost('entity');
$settings = $this->getRequest()->getPost('settings');
if (empty($settings['namespace'])) {
$error = new Varien_Object();
$error->setField('settings_namespace');
$error->setMessage(Mage::helper('modulecreator')->__('Fill in the Namespace'));
$errors[] = $error->toArray();
}
if (empty($settings['module_name'])) {
$error = new Varien_Object();
$error->setField('settings_module_name');
$error->setMessage(Mage::helper('modulecreator')->__('Fill in the Module name'));
$errors[] = $error->toArray();
} else {
$validModule = Mage::helper('modulecreator')->validateModuleName($settings['module_name'], $settings['current_extension']);
if (is_string($validModule)) {
$error = new Varien_Object();
$error->setMessage($validModule);
$error->setField('settings_module_name');
$errors[] = $error->toArray();
}
}
$validExtension = Mage::helper('modulecreator')->validateExtensionName($settings['namespace'], $settings['module_name'], $settings['current_extension']);
if (is_string($validExtension)) {
$error = new Varien_Object();
$error->setMessage($validExtension);
$errors[] = $error->toArray();
}
if (empty($entities)) {
$error = new Varien_Object();
$error->setMessage(Mage::helper('modulecreator')->__('Add at least one entity'));
$errors[] = $error->toArray();
} else {
//validate each entity
$noAttributeEntities = false;
$noNameEntities = false;
foreach ($entities as $key => $entity) {
if (empty($entity['name_singular'])) {
$error = new Varien_Object();
$error->setMessage(Mage::helper('modulecreator')->__('This is a required field.'));
$error->setField('entity_' . $key . '_name_singular');
$errors[] = $error->toArray();
}
if (empty($entity['name_plural'])) {
$error = new Varien_Object();
$error->setMessage(Mage::helper('modulecreator')->__('This is a required field.'));
$error->setField('entity_' . $key . '_name_plural');
$errors[] = $error->toArray();
}
if (!isset($entity['attributes']) && !$noAttributeEntities) {
$error = new Varien_Object();
$error->setMessage(Mage::helper('modulecreator')->__('There are entities without attribtues. Add attributes or remove them before continuing.'));
$errors[] = $error->toArray();
$noAttributeEntities = true;
} elseif (isset($entity['attributes'])) {
//validate attributes
foreach ($entity['attributes'] as $attrKey => $attribute) {
if (is_numeric($attrKey)) {
$validAttribute = Mage::helper('modulecreator')->validateAttributeName($attribute['code']);
if (is_string($validAttribute)) {
$error = new Varien_Object();
$error->setMessage($validAttribute);
$error->setField('attribute_' . $key . '_' . $attrKey . '_code');
$errors[] = $error->toArray();
}
}
}
}
if ((!isset($entity['attributes']) || is_null($entity['attributes']['is_name'])) && !$noNameEntities) {
$error = new Varien_Object();
$error->setMessage(Mage::helper('modulecreator')->__('Each entity must have an attribute set to behave as "Name"'));
$errors[] = $error->toArray();
$noNameEntities = true;
}
$validEntity = Mage::helper('modulecreator')->validateEntityName($settings['module_name'], @$entity['name_singular'], $settings['current_extension']);
if (is_string($validEntity)) {
$error = new Varien_Object();
$error->setMessage($validEntity);
$error->setField('entity_' . $key . '_name_singular');
$errors[] = $error->toArray();
}
}
}
try {
$module = $this->_initModuleFromData($data);
} catch (Exception $e) {
$error = new Varien_Object();
$error->setMessage($e->getMessage());
//.........这里部分代码省略.........