Varien_Object PHP Class Code Examples

This page contains top rated real world PHP examples of class Varien_Object extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: PurchaseordersController.php Project: cabrerabywaters/magentoSunshine
0
 public function exportPostAction($data)
 {
     $headers = new Varien_Object(array('ID' => Mage::helper('inventorypurchasing')->__('ID'), 'Name' => Mage::helper('inventorypurchasing')->__('Name'), 'SKU' => Mage::helper('inventorypurchasing')->__('SKU'), 'Cost' => Mage::helper('inventorypurchasing')->__('Cost'), 'Price' => Mage::helper('inventorypurchasing')->__('Price'), 'Warehouse' => Mage::helper('inventorypurchasing')->__('Warehouse'), 'Supplyneeds' => Mage::helper('inventorypurchasing')->__('Supplyneeds'), 'Supplier' => Mage::helper('inventorypurchasing')->__('Supplier')));
     $template = '"{{ID}}","{{Name}}","{{SKU}}","{{Cost}}","{{Price}}","{{Supplyneeds}}","{{Warehouse}}","{{Supplier}}"';
     $content = $headers->toString($template);
     if ($data['product_list']) {
         $info = array();
         $list = explode(';', $data['product_list']);
         $arr = Mage::helper('inventoryplus/supplyneeds')->filterList($list);
         foreach ($arr as $productId => $qty) {
             $product = Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('entity_id', $productId)->addAttributeToSelect('*')->getFirstItem();
             $warehouse = Mage::getModel('inventoryplus/warehouse')->getCollection()->addFieldToFilter('warehouse_id', $data['warehouse_select'])->getFirstItem()->getName();
             $supplier = Mage::getModel('inventorypurchasing/supplier')->getCollection()->addFieldToFilter('supplier_id', $data['supplier_select'])->getFirstItem()->getName();
             $cost = Mage::getModel('inventorypurchasing/supplier_product')->getCollection()->addFieldToFilter('product_id', $productId)->getFirstItem()->getCost();
             $info['ID'] = $productId;
             $info['Name'] = $product->getName();
             $info['SKU'] = $product->getSku();
             $info['Cost'] = $cost;
             $info['Price'] = $product->getPrice();
             $info['Supplyneeds'] = $qty;
             $info['Warehouse'] = $warehouse;
             $info['Supplier'] = $supplier;
             $csv_content = new Varien_Object($info);
             $content .= "\n";
             $content .= $csv_content->toString($template);
         }
     }
     $this->_prepareDownloadResponse('supplyneeds.csv', $content);
 }
Example #2
Show file File: Payment.php Project: MadMaxAi/sage-pay-suite-ce
0
 public function recurringOthers($oldOrder, $newOrder)
 {
     $rc = new Varien_Object();
     $orderId = $oldOrder->getId();
     $newOrder->setIsRecurring(1);
     $trn = Mage::getModel('sagepaysuite2/sagepaysuite_transaction')->loadByParent($orderId);
     $amount = $newOrder->getPayment()->getAmountOrdered();
     try {
         $paymentApi = Mage::getModel('sagepaysuite/api_payment');
         $auth = new Varien_Object();
         $paymentApi->setMcode($paymentApi->realIntegrationCode($trn->getIntegration()));
         $repeat = $paymentApi->repeat($trn, $amount);
         if ($repeat['Status'] == 'OK') {
             $repeatTransaction = clone $trn;
             $repeatTransaction->setId(null)->setOrderId($newOrder->getId())->setReleased(null)->setStatus($repeat['Status'])->setStatusDetail($repeat['StatusDetail'])->setVpsTxId($repeat['VPSTxId'])->setTxAuthNo($repeat['TxAuthNo'])->setSecurityKey($repeat['SecurityKey'])->setIntegration($trn->getIntegration())->setVendorTxCode($repeat['_requestvendor_'])->setVpsProtocol($trn->getVpsProtocol())->setVendorname($trn->getVendorname())->setMode($trn->getMode())->setTxType(strtoupper($repeat['_requesttxtype_']))->setTrnCurrency($trn->getTrnCurrency())->setTrndate($this->getDate())->save();
             $auth = Mage::getModel('sagepaysuite2/sagepaysuite_action')->load($repeat['_requestvendor_'], 'vendor_tx_code');
             $newOrder->getPayment()->setLastTransId($repeat['VPSTxId']);
         } else {
             $rc->setPaymentDetails("ERROR: Could not repeat payment.");
             $rc->setPaymentOK(false);
         }
         if ($auth->getId()) {
             //$rc->setPaymentDetails($auth->getStatusDetail());
             $rc->setPaymentOK(true);
         } else {
             $rc->setPaymentDetails("ERROR: Could not load authorisation.");
             $rc->setPaymentOK(false);
         }
     } catch (Exception $e) {
         $rc->setPaymentDetails($e->getMessage());
         $rc->setPaymentOK(false);
         Mage::logException($e);
     }
     return $rc;
 }
Example #3
Show file File: SagepayreportingController.php Project: MadMaxAi/sage-pay-suite-ce
0
 public function transactionDetailModalAction()
 {
     if ($this->getRequest()->getParam('vendortxcode') || $this->getRequest()->getParam('vpstxid')) {
         $id = $this->getRequest()->getParam('vendortxcode') ? $this->getRequest()->getParam('vendortxcode') : $this->getRequest()->getParam('vpstxid');
         try {
             if ($this->getRequest()->getParam('vpstxid')) {
                 $response = Mage::getModel('sagepayreporting/sagepayreporting')->getTransactionDetails(null, urldecode($id));
                 $relatedTrns = Mage::getModel('sagepayreporting/sagepayreporting')->getRelatedTransactions(urldecode($id));
                 if ($relatedTrns['ok'] === true) {
                     Mage::register('sagepay_related_transactions', $relatedTrns['result']);
                 } else {
                     $response = new Varien_Object();
                     $response->setError($relatedTrns['result']);
                     $response->setErrorcode('-1');
                 }
             } else {
                 Mage::register('sagepay_related_transactions', new Varien_Object());
                 $response = Mage::getModel('sagepayreporting/sagepayreporting')->getTransactionDetails($id, null);
             }
         } catch (Exception $exc) {
             //$this->_getSession()->addError($exc->getMessage());
             $response = new Varien_Object();
             $response->setError($exc->getMessage());
             $response->setErrorcode('-1');
         }
         if ($response->getErrorcode() == '0000') {
             Mage::register('sagepay_detail', $response);
         } else {
             $this->_getSession()->addError(Mage::helper('sagepayreporting/error')->parseError($response->getError(), Mage::getStoreConfig('sagepayreporting/account/vendor')));
         }
     } else {
         Mage::register('sagepay_detail', null);
     }
     $this->loadLayout('popup_sagepay')->renderLayout();
 }
Example #4
Show file File: ObserverTest.php Project: igorvasiliev4/magento_code
0
 public function testAppendReceiverEmail()
 {
     $request = new Dhl_Intraship_Model_Soap_Client_Shipment_Create();
     $parcel = new Varien_Object();
     $shipment = new Varien_Object();
     $billingAddress = new Varien_Object();
     $billingAddress->setPackageNotification(true);
     $shipment->setBillingAddress($billingAddress);
     $parcel->setShipment($shipment);
     $receiver = new Varien_Object();
     $receiver->setEmail('test@test.de');
     $shipmentOrder = array('Shipment' => array('Receiver' => array('Communication' => array('email' => null))));
     $params = new Dhl_Intraship_Model_Soap_Client_Shipment_Create();
     $params->offsetSet('ShipmentOrder', $shipmentOrder);
     $request->offsetSet('shipment', $parcel);
     $request->offsetSet('receiver', $receiver);
     $request->offsetSet('params', $params);
     $observer = Mage::getModel('dhlaccount/observer');
     $event = new Varien_Event_Observer();
     $eventData = new Varien_Object();
     $eventData->setRequest($request);
     $event->setEvent($eventData);
     $observer->appendReceiverEmail($event);
     $shipmentOrder = $request->offsetGet('params')->offsetGet('ShipmentOrder');
     $this->assertTrue(array_key_exists('Shipment', $shipmentOrder));
     $this->assertTrue(array_key_exists('Receiver', $shipmentOrder['Shipment']));
     $this->assertTrue(array_key_exists('Communication', $shipmentOrder['Shipment']['Receiver']));
     $this->assertTrue(array_key_exists('email', $shipmentOrder['Shipment']['Receiver']['Communication']));
     $this->assertEquals('test@test.de', $shipmentOrder['Shipment']['Receiver']['Communication']['email']);
 }
 /**
  * Initialise the taxonomy data
  *
  * @return $this
  */
 protected function _initTaxonomies()
 {
     if (!is_null(self::$_taxonomies)) {
         return $this;
     }
     self::$_taxonomies = false;
     $transportObject = new Varien_Object(array('taxonomies' => false));
     Mage::dispatchEvent('wordpress_app_init_taxonomies', array('transport' => $transportObject));
     if ($transportObject->getTaxonomies()) {
         self::$_taxonomies = $transportObject->getTaxonomies();
     } else {
         $blogPrefix = Mage::helper('wordpress')->isWordPressMU() && Mage::helper('wp_addon_multisite')->canRun() && Mage::helper('wp_addon_multisite')->isDefaultBlog();
         $bases = array('category' => Mage::helper('wordpress')->getWpOption('category_base'), 'post_tag' => Mage::helper('wordpress')->getWpOption('tag_base'));
         foreach ($bases as $baseType => $base) {
             if ($blogPrefix && $base && strpos($base, '/blog') === 0) {
                 $bases[$baseType] = substr($base, strlen('/blog'));
             }
         }
         self::$_taxonomies = array('category' => Mage::getModel('wordpress/term_taxonomy')->setData(array('type' => 'category', 'taxonomy_type' => 'category', 'labels' => array('name' => 'Categories', 'singular_name' => 'Category'), 'public' => true, 'hierarchical' => true, 'rewrite' => array('hierarchical' => true, 'slug' => $bases['category']), '_builtin' => true)), 'post_tag' => Mage::getModel('wordpress/term_taxonomy')->setData(array('type' => 'post_tag', 'taxonomy_type' => 'post_tag', 'labels' => array('name' => 'Tags', 'singular_name' => 'Tag'), 'public' => true, 'hierarchical' => false, 'rewrite' => array('slug' => $bases['post_tag']), '_builtin' => true)));
     }
     if (isset(self::$_taxonomies['category'])) {
         $helper = Mage::helper('wordpress');
         $canRemoveCategoryPrefix = $helper->isPluginEnabled('wp-no-category-base/no-category-base.php') || $helper->isPluginEnabled('wp-remove-category-base/wp-remove-category-base.php') || $helper->isPluginEnabled('remove-category-url/remove-category-url.php') || Mage::helper('wp_addon_wordpressseo')->canRemoveCategoryBase();
         if ($canRemoveCategoryPrefix) {
             self::$_taxonomies['category']->setSlug('');
         }
     }
     $transportObject = new Varien_Object(array('taxonomies' => self::$_taxonomies));
     Mage::dispatchEvent('wordpress_app_init_taxonomies_after', array('transport' => $transportObject, 'helper' => $this));
     self::$_taxonomies = $transportObject->getTaxonomies();
     return $this;
 }
Example #6
Show file File: Fee.php Project: AndreKlang/Magento-Payex
0
 public function initTotals()
 {
     $parent = $this->getParentBlock();
     $paymentMethod = $parent->getOrder()->getPayment()->getMethodInstance()->getCode();
     if (!in_array($paymentMethod, self::$_allowed_methods)) {
         return $this;
     }
     if ($parent->getOrder()->getBasePayexPaymentFeeTax()) {
         $total = new Varien_Object();
         $total->setLabel(Mage::helper('payex')->__('Payment fee (Incl.Tax)'));
         $total->setValue($parent->getOrder()->getPayexPaymentFee() + $parent->getOrder()->getPayexPaymentFeeTax());
         $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee() + $parent->getOrder()->getPayexBasePaymentFeeTax());
         $total->setCode('payex_payment_fee_with_tax');
         $parent->addTotalBefore($total, 'tax');
     }
     if ($parent->getOrder()->getBasePayexPaymentFee()) {
         $total = new Varien_Object();
         $total->setLabel(Mage::helper('payex')->__('Payment fee (Excl.Tax)'));
         $total->setValue($parent->getOrder()->getPayexPaymentFee());
         $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee());
         $total->setCode('payex_payment_fee');
         $parent->addTotalBefore($total, 'payex_payment_fee_with_tax');
     }
     return $this;
 }
Example #7
Show file File: Checkout.php Project: cnglobal-sl/caterez
0
 /**
  * Compare two shipping options based on their amounts
  *
  * This function is used as a callback comparison function in shipping options sorting process
  * @see self::_prepareShippingOptions()
  *
  * @param Varien_Object $option1
  * @param Varien_Object $option2
  * @return integer
  */
 protected static function cmpShippingOptions(Varien_Object $option1, Varien_Object $option2)
 {
     if ($option1->getAmount() == $option2->getAmount()) {
         return 0;
     }
     return $option1->getAmount() < $option2->getAmount() ? -1 : 1;
 }
Example #8
Show file File: Navigation.php Project: buttasg/cowgirlk
0
 /**
  * Retrives frame object
  * @param Varien_Object $object Category Tree Node
  * @return Varien_Object
  */
 protected function _getFrame(Varien_Object $object, $level = 1)
 {
     $frame = new Varien_Object();
     $frame->setFrameId('category' . $object->getId());
     $frame->setFrameCategoryId($object->getId());
     $frame->setHeader($object->getName());
     $frame->setLevel($level + 1);
     if (Mage::getStoreConfig('catalog/frontend/flat_catalog_category')) {
         $frame->setChildren($object->getChildrenNodes());
     } else {
         $frame->setChildren($object->getChildren());
     }
     $frame->setChildrenCount($this->__getChildrenCount($object));
     if (Mage::getStoreConfig('catalog/frontend/flat_catalog_category')) {
         if (is_array($frame->getChildrenNodes()) || is_object($frame->getChildrenNodes()) && get_class($frame->getChildrenNodes()) == 'Varien_Data_Tree_Node_Collection') {
             foreach ($frame->getChildrenNodes() as $child) {
                 $this->_frames[] = $this->_getFrame($child, $level + 1);
             }
         }
     } else {
         if (is_array($frame->getChildren()) || is_object($frame->getChildren()) && get_class($frame->getChildren()) == 'Varien_Data_Tree_Node_Collection') {
             foreach ($frame->getChildren() as $child) {
                 $this->_frames[] = $this->_getFrame($child, $level + 1);
             }
         }
     }
     return $frame;
 }
Example #9
Show file File: AttributeController.php Project: par-orillonsoft/magento_work
0
 /**
  * Attributes validation action
  *
  */
 public function validateAction()
 {
     $response = new Varien_Object();
     $response->setError(false);
     $attributesData = $this->getRequest()->getParam('attributes', array());
     $data = new Varien_Object();
     try {
         if ($attributesData) {
             $dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
             $storeId = $this->_getHelper()->getSelectedStoreId();
             foreach ($attributesData as $attributeCode => $value) {
                 $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
                 if (!$attribute->getAttributeId()) {
                     unset($attributesData[$attributeCode]);
                     continue;
                 }
                 $data->setData($attributeCode, $value);
                 $attribute->getBackend()->validate($data);
             }
         }
     } catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
         $response->setError(true);
         $response->setAttribute($e->getAttributeCode());
         $response->setMessage($e->getMessage());
     } catch (Mage_Core_Exception $e) {
         $response->setError(true);
         $response->setMessage($e->getMessage());
     } catch (Exception $e) {
         $this->_getSession()->addException($e, $this->__('An error occurred while updating the product(s) attributes.'));
         $this->_initLayoutMessages('adminhtml/session');
         $response->setError(true);
         $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
     }
     $this->getResponse()->setBody($response->toJson());
 }
Example #10
Show file File: Mirasvit_Helpdesk_Helper_Customer.php Project: cesarfelip3/clevermage_new
0
 public function getCustomerByPost($params)
 {
     $customer = $this->_getCustomer();
     // Patch for custom Contact Us form with ability to change email or name of customer (HDMX-98)
     if ($customer->getId() > 0 && !isset($params['customer_email']) && !isset($params['customer_name'])) {
         return $customer;
     }
     $email = $params['customer_email'];
     $name = $params['customer_name'];
     $customers = Mage::getModel('customer/customer')->getCollection();
     $customers->addAttributeToSelect('*')->addAttributeToFilter('email', $email);
     if ($customers->count() > 0) {
         return $customers->getFirstItem();
     }
     $c = Mage::getModel('customer/customer');
     $c->getEmail();
     $c->setEmail('aaa');
     /** @var Mage_Customer_Model_Customer $address */
     $address = $customers->getFirstItem();
     if ($address->getId()) {
         $customer = new Varien_Object();
         $customer->setName($address->getName());
         $customer->setEmail($address->getEmail());
         $customer->setQuoteAddressId($address->getId());
         return $customer;
     }
     $customer = new Varien_Object();
     $customer->setName($name);
     $customer->setEmail($email);
     return $customer;
 }
Example #11
Show file File: Product.php Project: chucky515/Magento-CE-Mirror
0
 /**
  * Process $buyRequest and sets its options before saving configuration to some product item.
  * This method is used to attach additional parameters to processed buyRequest.
  *
  * $params holds parameters of what operation must be performed:
  * - 'current_config', Varien_Object or array - current buyRequest that configures product in this item,
  *   used to restore currently attached files
  * - 'files_prefix': string[a-z0-9_] - prefix that was added at frontend to names of file inputs,
  *   so they won't intersect with other submitted options
  *
  * @param Varien_Object|array $buyRequest
  * @param Varien_Object|array $params
  * @return Varien_Object
  */
 public function addParamsToBuyRequest($buyRequest, $params)
 {
     if (is_array($buyRequest)) {
         $buyRequest = new Varien_Object($buyRequest);
     }
     if (is_array($params)) {
         $params = new Varien_Object($params);
     }
     // Ensure that currentConfig goes as Varien_Object - for easier work with it later
     $currentConfig = $params->getCurrentConfig();
     if ($currentConfig) {
         if (is_array($currentConfig)) {
             $params->setCurrentConfig(new Varien_Object($currentConfig));
         } else {
             if (!$currentConfig instanceof Varien_Object) {
                 $params->unsCurrentConfig();
             }
         }
     }
     /*
      * Notice that '_processing_params' must always be object to protect processing forged requests
      * where '_processing_params' comes in $buyRequest as array from user input
      */
     $processingParams = $buyRequest->getData('_processing_params');
     if (!$processingParams || !$processingParams instanceof Varien_Object) {
         $processingParams = new Varien_Object();
         $buyRequest->setData('_processing_params', $processingParams);
     }
     $processingParams->addData($params->getData());
     return $buyRequest;
 }
Example #12
Show file File: CheckoutController.php Project: Madhurabhat/test
0
 protected function _isCaptchaCorrect()
 {
     if (!Mage::helper('aitcheckout/captcha')->checkIfCaptchaEnabled()) {
         return true;
         //not 1.7
     }
     $formId = $this->_getCheckoutCaptchaMethod();
     $helper = Mage::helper('aitcheckout/captcha');
     if ($helper->isCaptchaPassed($formId)) {
         return true;
     }
     $observer = new Varien_Object();
     $observer->setControllerAction($this);
     Mage::getSingleton('captcha/observer')->checkGuestCheckout($observer);
     Mage::getSingleton('captcha/observer')->checkRegisterCheckout($observer);
     $response = $this->getResponse();
     if ($response->getBody()) {
         $result = Mage::helper('core')->jsonDecode($response->getBody());
         if ($result['error'] == 1) {
             $result = new Varien_Object($result);
             $helper->renewCaptcha($result, $formId);
             $response->setBody(Mage::helper('core')->jsonEncode($this->_extractStepOutput('billing', $result->__toArray())));
             return false;
         }
     }
     $helper->setCaptchaAsConfirmed($formId);
     return true;
 }
Example #13
Show file File: Totals.php Project: par-orillonsoft/Magento
0
 /**
  * Initialize order totals array
  *
  * @return Mage_Sales_Block_Order_Totals
  */
 protected function _initTotals()
 {
     parent::_initTotals();
     $this->removeTotal('base_grandtotal');
     if ((double) $this->getSource()->getAdjustmentPositive()) {
         $total = new Varien_Object(array('code' => 'adjustment_positive', 'value' => $this->getSource()->getAdjustmentPositive(), 'label' => $this->__('Adjustment Refund')));
         $this->addTotal($total);
     }
     if ((double) $this->getSource()->getAdjustmentNegative()) {
         $total = new Varien_Object(array('code' => 'adjustment_negative', 'value' => $this->getSource()->getAdjustmentNegative(), 'label' => $this->__('Adjustment Fee')));
         $this->addTotal($total);
     }
     /**
             <?php if ($this->getCanDisplayTotalPaid()): ?>
             <tr>
        <td colspan="6" class="a-right"><strong><?php echo $this->__('Total Paid') ?></strong></td>
        <td class="last a-right"><strong><?php echo $_order->formatPrice($_creditmemo->getTotalPaid()) ?></strong></td>
             </tr>
             <?php endif; ?>
             <?php if ($this->getCanDisplayTotalRefunded()): ?>
             <tr>
        <td colspan="6" class="a-right"><strong><?php echo $this->__('Total Refunded') ?></strong></td>
        <td class="last a-right"><strong><?php echo $_order->formatPrice($_creditmemo->getTotalRefunded()) ?></strong></td>
             </tr>
             <?php endif; ?>
             <?php if ($this->getCanDisplayTotalDue()): ?>
             <tr>
        <td colspan="6" class="a-right"><strong><?php echo $this->__('Total Due') ?></strong></td>
        <td class="last a-right"><strong><?php echo $_order->formatPrice($_creditmemo->getTotalDue()) ?></strong></td>
             </tr>
             <?php endif; ?>
     */
     return $this;
 }
Frequently Used Methods