Example #1
0
 public function getLastNotice()
 {
     if ($this->showExtendwarePopup === false) {
         return parent::getLastNotice();
     }
     static $lastNotice = false;
     if ($lastNotice === false) {
         $lastNotice = null;
         $message = Mage::helper('ewcore/notification')->getMessage();
         if ($message) {
             $lastNotice = new Varien_Object();
             $lastNotice->setTitle($message->getSubject());
             $lastNotice->setDescription($message->getSummary());
             $lastNotice->setUrl($this->getUrl('extendware_ewcore/adminhtml_message/edit', array('id' => $message->getId())));
             $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR);
             switch ($message->getSeverity()) {
                 case 'notice':
                     $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE);
                     break;
                 case 'minor':
                     $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR);
                     break;
                 case 'major':
                     $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR);
                     break;
                 case 'critical':
                     $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_CRITICAL);
                     break;
             }
         }
     }
     return $lastNotice;
 }
Example #2
0
 /**
  * Prepare grid collection
  */
 protected function _prepareCollection()
 {
     $collection = new Varien_Data_Collection();
     $layout = $this->getLayout();
     $update = $layout->getUpdate();
     $design = Mage::getSingleton('core/design_package');
     $layoutXML = $update->getFileLayoutUpdatesXml('frontend', $design->getPackageName(), $design->getTheme('layout'), 0);
     $xpath = $layoutXML->xpath('//action[@method="setEsi"]');
     foreach ($xpath as $x) {
         $esi = new Varien_Object();
         $handle = $x->xpath('ancestor::node()[last()-2]');
         $handleName = $handle[0]->label ? $handle[0]->label : $handle[0]->getName();
         $parentBlock = $x->xpath('parent::*');
         $parentBlockName = $parentBlock[0]->getAttribute('name');
         $parentBlockDescription = $parentBlock[0]->getAttribute('description');
         $cacheType = $x->params->cache_type ? $x->params->cache_type : "global";
         $esi->setId($parentBlockName);
         $esi->setHandle($handleName);
         $esi->setBlockName($parentBlockName);
         $esi->setDescription($parentBlockDescription);
         $esi->setCacheType($cacheType);
         try {
             $collection->addItem($esi);
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
 public function saveAction()
 {
     $data = new Varien_Object($this->getRequest()->getParam('payment', array()));
     $data->setCustomerId(Mage::helper('iugu')->getCustomerId());
     $data->setDescription(Mage::getModel('core/date')->timestamp(time()));
     $result = Mage::getSingleton('iugu/api')->savePaymentMethod($data);
     if ($result->getErrors()) {
         Mage::getSingleton('customer/session')->addError($this->__('An error occurred while saving the credit card.'));
     } else {
         Mage::getSingleton('customer/session')->addSuccess(Mage::helper('iugu')->__('Credit card has been saved.'));
     }
     $this->_redirect('*/*/');
 }
Example #4
0
 protected function _place($payment, $amount)
 {
     $order = $payment->getOrder();
     $payer = Mage::helper('iugu')->getPayerInfoFromOrder($payment->getOrder());
     $items = Mage::helper('iugu')->getItemsFromOrder($payment->getOrder());
     // Verify if needs add interest
     $interestRate = $this->getInterestRate($payment->getInstallments());
     $totalWithInterest = $this->calcTotalWithInterest($amount, $interestRate);
     if ($totalWithInterest - $amount > 0) {
         $item = new Varien_Object();
         $item->setDescription(Mage::helper('iugu')->__('Interest'));
         $item->setQuantity(1);
         $item->setPriceCents(Mage::helper('iugu')->formatAmount($totalWithInterest - $amount));
         $items[] = $item;
     }
     // Save Payment method
     if (!$payment->getIuguCustomerPaymentMethodId() && $payment->getIuguSave()) {
         $data = new Varien_Object();
         $data->setToken($payment->getIuguToken());
         $data->setCustomerId(Mage::helper('iugu')->getCustomerId());
         $data->setDescription(Mage::getModel('core/date')->timestamp(time()));
         $result = Mage::getSingleton('iugu/api')->savePaymentMethod($data);
         if ($result->getId()) {
             $payment->setIuguCustomerPaymentMethodId($result->getId());
         }
     }
     // Set Charge Data
     $data = new Varien_Object();
     if ($payment->getIuguCustomerPaymentMethodId()) {
         $data->setCustomerPaymentMethodId($payment->getIuguCustomerPaymentMethodId());
     } else {
         $data->setToken($payment->getIuguToken());
     }
     $data->setMonths($payment->getInstallments())->setEmail($order->getCustomerEmail())->setItems($items)->setPayer($payer);
     // Discount
     if ($order->getBaseDiscountAmount()) {
         $data->setDiscountCents(Mage::helper('iugu')->formatAmount(abs($order->getBaseDiscountAmount())));
     }
     // Tax
     if ($order->getBaseTaxAmount()) {
         $data->setTaxCents($this->formatAmount($order->getBaseTaxAmount()));
     }
     // Charge
     $result = Mage::getSingleton('iugu/api')->charge($data);
     if (!$result->getSuccess()) {
         Mage::throwException(Mage::helper('iugu')->__('Transaction failed, please try again or contact the card issuing bank.'));
     }
     // Set iugu info
     $payment->setIuguInvoiceId($result->getInvoiceId())->setIuguTotalWithInterest($totalWithInterest)->setIuguUrl($result->getUrl())->setIuguPdf($result->getPdf())->setTransactionId($result->getInvoiceId())->setIsTransactionClosed(0)->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('message' => $result->getMessage()));
     return $this;
 }
Example #5
0
 /**
  * Retrieve actions collection
  *
  * @return array
  * @throws Exception
  */
 protected function _getActions()
 {
     $config = Mage::getSingleton('smile_magecache/config');
     $actionsConfig = $config->getActionConfig();
     $items = array();
     $i = 0;
     foreach ($actionsConfig as $code => $actionConfig) {
         $action = new Varien_Object();
         $action->setPosition($i++);
         $action->setCode($actionConfig->getCode());
         $action->setName($actionConfig->getModel()->getLabel());
         $action->setDescription($actionConfig->getModel()->getDescription());
         $items[] = $action;
     }
     return $items;
 }
Example #6
0
 public function getItemsFromOrder($order)
 {
     $items = array();
     foreach ($order->getAllVisibleItems() as $data) {
         $item = new Varien_Object();
         $item->setDescription($data->getName());
         $item->setQuantity($data->getQtyOrdered());
         $item->setPriceCents($this->formatAmount($data->getBasePrice()));
         $items[] = $item;
     }
     // Shipping
     if ($order->getBaseShippingAmount() > 0) {
         $item = new Varien_Object();
         $item->setDescription($this->__('Shipping & Handling') . ' (' . $order->getShippingDescription() . ')');
         $item->setQuantity(1);
         $item->setPriceCents($this->formatAmount($order->getBaseShippingAmount()));
         $items[] = $item;
     }
     return $items;
 }
Example #7
0
 /**
  * Prepare collection of errors
  *
  * @return Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Grid
  */
 protected function _prepareCollection()
 {
     $collection = new Varien_Data_Collection();
     $removeButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button', '', array('class' => 'delete', 'label' => '', 'onclick' => 'addBySku.removeFailedItem(this)', 'type' => 'button'))->toHtml();
     /* @var $parentBlock Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Abstract */
     $parentBlock = $this->getParentBlock();
     foreach ($parentBlock->getFailedItems() as $affectedItem) {
         // Escape user-submitted input
         if (isset($affectedItem['item']['qty'])) {
             $affectedItem['item']['qty'] = empty($affectedItem['item']['qty']) ? '' : (double) $affectedItem['item']['qty'];
         }
         $item = new Varien_Object();
         $item->setCode($affectedItem['code']);
         if (isset($affectedItem['error'])) {
             $item->setError($affectedItem['error']);
         }
         $item->addData($affectedItem['item']);
         $item->setId($item->getSku());
         /* @var $product Mage_Catalog_Model_Product */
         $product = Mage::getModel('catalog/product');
         if (isset($affectedItem['item']['id'])) {
             $productId = $affectedItem['item']['id'];
             $item->setProductId($productId);
             $product->load($productId);
             /* @var $stockStatus Mage_CatalogInventory_Model_Stock_Status */
             $stockStatus = Mage::getModel('cataloginventory/stock_status');
             $status = $stockStatus->getProductStatus($productId, $this->getWebsiteId());
             if (!empty($status[$productId])) {
                 $product->setIsSalable($status[$productId]);
             }
             $item->setPrice(Mage::helper('core')->formatPrice($product->getPrice()));
         }
         $descriptionBlock = $this->getLayout()->createBlock('enterprise_checkout/adminhtml_sku_errors_grid_description', '', array('product' => $product, 'item' => $item));
         $item->setDescription($descriptionBlock->toHtml());
         $item->setRemoveButton($removeButtonHtml);
         $collection->addItem($item);
     }
     $this->setCollection($collection);
     return $this;
 }
 protected function _applyPostPageLogic($object, $type = 'post')
 {
     $meta = new Varien_Object(array('title' => $this->_getTitleFormat($type)));
     if (($value = trim($object->getMetaValue('_aioseop_title'))) !== '') {
         $data = $this->getRewriteData();
         $data[$type . '_title'] = $value;
         $this->setRewriteData($data);
     }
     if (($value = trim($object->getMetaValue('_aioseop_description'))) !== '') {
         $meta->setDescription($value);
     }
     if (($value = trim($object->getMetaValue('_aioseop_keywords'))) !== '') {
         $meta->setKeywords($value);
     }
     if ($type === 'post') {
         $keywords = rtrim($meta->getKeywords(), ',') . ',';
         if ($this->getUseCategories()) {
             foreach ($object->getParentCategories() as $category) {
                 $keywords .= $category->getName() . ',';
             }
         }
         if ($this->getUseTagsAsKeywords()) {
             foreach ($object->getTags() as $tag) {
                 $keywords .= $tag->getName() . ',';
             }
         }
         $meta->setKeywords(trim($keywords, ','));
     }
     $this->_applyMeta($meta->getData());
     return $this;
 }
 public function getConfigAsObject($code)
 {
     $xml = $this->getConfigAsXml($code);
     $object = new Varien_Object();
     if ($xml === null) {
         return $object;
     }
     // Save all nodes to object data
     $object->setCode($code);
     $object->setData($xml->asCanonicalArray());
     // Set module for translations etc..
     $module = $object->getData('@/module');
     $object->setModule($module ? $module : 'customgrid');
     // Set type
     $type = $object->getData('@/type');
     $object->setType($type);
     // Translate name, description and help
     $helper = Mage::helper($object->getModule());
     if ($object->hasName()) {
         $object->setName($helper->__((string) $object->getName()));
     }
     if ($object->hasDescription()) {
         $object->setDescription($helper->__((string) $object->getDescription()));
     }
     if ($object->hasHelp()) {
         $object->setHelp($helper->__((string) $object->getHelp()));
     }
     if ($this->_acceptParameters) {
         // Correct element parameters and convert its data to objects if needed
         $params = $object->getData('parameters');
         $newParams = array();
         if (is_array($params)) {
             $sortOrder = 0;
             foreach ($params as $key => $data) {
                 if (is_array($data)) {
                     $data['key'] = $key;
                     $data['sort_order'] = isset($data['sort_order']) ? (int) $data['sort_order'] : $sortOrder;
                     // Prepare values (for dropdowns) specified directly in configuration
                     $values = array();
                     if (isset($data['values']) && is_array($data['values'])) {
                         foreach ($data['values'] as $value) {
                             if (isset($value['label']) && isset($value['value'])) {
                                 $values[] = $value;
                             }
                         }
                     }
                     $data['values'] = $values;
                     // Prepare helper block object
                     if (isset($data['helper_block'])) {
                         $helper = new Varien_Object();
                         if (isset($data['helper_block']['data']) && is_array($data['helper_block']['data'])) {
                             $helper->addData($data['helper_block']['data']);
                         }
                         if (isset($data['helper_block']['type'])) {
                             $helper->setType($data['helper_block']['type']);
                         }
                         $data['helper_block'] = $helper;
                     }
                     $newParams[$key] = new Varien_Object($data);
                     $sortOrder++;
                 }
             }
         }
         uasort($newParams, array($this, '_sortParameters'));
         $object->setData('parameters', $newParams);
     }
     return $object;
 }
Example #10
0
 protected function _applyPostPageLogic($object, $type = 'post')
 {
     $meta = new Varien_Object(array('title' => $this->_getTitleFormat($type), 'description' => trim($this->getData('metadesc_' . $type)), 'keywords' => trim($this->getData('metakey_' . $type))));
     if (($value = trim($object->getMetaValue('_yoast_wpseo_title'))) !== '') {
         $data = $this->getRewriteData();
         $data['title'] = $value;
         $this->setRewriteData($data);
     }
     if (($value = trim($object->getMetaValue('_yoast_wpseo_metadesc'))) !== '') {
         $meta->setDescription($value);
     }
     $robots = array();
     $noIndex = (int) $object->getMetaValue('_yoast_wpseo_meta-robots-noindex');
     if ($noIndex === 0) {
         $robots['noindex'] = '';
     } else {
         if ($noIndex === 1) {
             $robots['noindex'] = '';
         } else {
             if ($noIndex === 2) {
                 $robots['index'] = '';
             } else {
                 if ($this->getNoindexPost()) {
                     $robots['noindex'] = '';
                 }
             }
         }
     }
     if ($object->getMetaValue('_yoast_wpseo_meta-robots-nofollow')) {
         $robots['nofollow'] = '';
     } else {
         $robots['follow'] = '';
     }
     if (($advancedRobots = trim($object->getMetaValue('_yoast_wpseo_meta-robots-adv'))) !== '') {
         if ($advancedRobots !== 'none') {
             $robots = explode(',', $advancedRobots);
         }
     }
     $robots = array_keys($robots);
     if (count($robots) > 0) {
         $meta->setRobots(implode(',', $robots));
     }
     $this->_applyMeta($meta->getData());
     if (($headBlock = $this->_getHeadBlock()) !== false) {
         if ($canon = $object->getMetaValue('_yoast_wpseo_canonical')) {
             $headBlock->removeItem('link_rel', $object->getUrl());
             $headBlock->addItem('link_rel', $canon, 'rel="canonical"');
         }
         $this->_addGooglePlusLinkRel($object->getAuthor());
     }
     return $this;
 }
 /**
  * Process the SEO values for the blog view page
  *
  * @param Varien_Object $object
  *  @param string $type
  * @param Varien_Object $page
  */
 protected function _applyPostPageLogic($object, $type = 'post')
 {
     $meta = new Varien_Object(array('title' => $this->_getTitleFormat($type), 'description' => trim($this->getData('metadesc_' . $type)), 'keywords' => trim($this->getData('metakey_' . $type))));
     if (($value = trim($object->getMetaValue('_yoast_wpseo_title'))) !== '') {
         $data = $this->getRewriteData();
         $data['title'] = $value;
         $this->setRewriteData($data);
     }
     if (($value = trim($object->getMetaValue('_yoast_wpseo_metadesc'))) !== '') {
         $meta->setDescription($value);
     }
     if (($value = trim($object->getMetaValue('_yoast_wpseo_metakeywords'))) !== '') {
         $meta->setKeywords($value);
     }
     $robots = array();
     $noIndex = (int) $object->getMetaValue('_yoast_wpseo_meta-robots-noindex');
     if ($noIndex === 0) {
         $robots['index'] = '';
     } else {
         if ($noIndex === 1) {
             $robots['noindex'] = '';
         } else {
             if ($noIndex === 2) {
                 $robots['index'] = '';
             } else {
                 if ($this->getNoindexPost()) {
                     $robots['noindex'] = '';
                 }
             }
         }
     }
     if ($object->getMetaValue('_yoast_wpseo_meta-robots-nofollow')) {
         $robots['nofollow'] = '';
     } else {
         $robots['follow'] = '';
     }
     if (($advancedRobots = trim($object->getMetaValue('_yoast_wpseo_meta-robots-adv'))) !== '') {
         if ($advancedRobots !== 'none') {
             $robots = explode(',', $advancedRobots);
         }
     }
     $robots = array_keys($robots);
     if (count($robots) > 0) {
         $meta->setRobots(implode(',', $robots));
     }
     $this->_applyMeta($meta->getData());
     if ($canon = $object->getMetaValue('_yoast_wpseo_canonical')) {
         $object->setCanonicalUrl($canon);
     }
     if (!$this->hasOpengraph() || (int) $this->getOpengraph() === 1) {
         $this->_addPostOpenGraphTags($object, $type);
     }
     if ($this->getTwitter()) {
         $this->_addTwitterCard(array('card' => $this->getTwitterCardType(), 'site' => $this->getTwitterSite() ? '@' . $this->getTwitterSite() : '', 'title' => $object->getPostTitle(), 'creator' => ($creator = $object->getAuthor()->getMetaValue('twitter')) ? '@' . $creator : ''));
     }
     return $this;
 }
Example #12
0
 /**
  * Возвращает сео-данные для текущей страницы
  *
  * Возвращает объект с методами:
  * getTitle() - заголовок H1
  * getDescription() - SEO текст
  * getMetaTitle()
  * getMetaKeyword()
  * getMetaDescription()
  *
  * Если для данной страницы нет СЕО, то возвращает пустой Varien_Object
  *
  * @return Varien_Object $result
  */
 public function getCurrentSeo()
 {
     if (Mage::app()->getStore()->getCode() == 'admin') {
         return new Varien_Object();
     }
     $uid = Mage::helper('mstcore/debug')->start();
     $isCategory = Mage::registry('current_category') || Mage::registry('category');
     $isProduct = Mage::registry('current_product') || Mage::registry('product');
     $isFilter = false;
     if ($isCategory) {
         $filters = Mage::getSingleton('catalog/layer')->getState()->getFilters();
         $isFilter = count($filters) > 0;
     }
     if ($isProduct) {
         $seo = Mage::getSingleton('seo/object_product');
     } elseif ($isCategory && $isFilter) {
         $seo = Mage::getSingleton('seo/object_filter');
     } elseif ($isCategory) {
         $seo = Mage::getSingleton('seo/object_category');
     } else {
         $seo = new Varien_Object();
     }
     if ($seoTempalate = $this->checkTempalateRule($isProduct, $isCategory, $isFilter)) {
         foreach ($seoTempalate->getData() as $k => $v) {
             if ($v) {
                 $seo->setData($k, $v);
             }
         }
     }
     if ($seoRewrite = $this->checkRewrite()) {
         foreach ($seoRewrite->getData() as $k => $v) {
             if ($v) {
                 $seo->setData($k, $v);
             }
         }
     }
     $storeId = Mage::app()->getStore()->getStoreId();
     $page = Mage::app()->getFrontController()->getRequest()->getParam('p');
     if (!$page) {
         $page = 1;
     }
     if ($isCategory && !$isProduct) {
         if ($this->_titlePage) {
             switch ($this->_config->getMetaTitlePageNumber($storeId)) {
                 case Mirasvit_Seo_Model_Config::META_TITLE_PAGE_NUMBER_BEGIN:
                     if ($page > 1) {
                         $seo->setMetaTitle(Mage::helper('seo')->__("Page %s | %s", $page, $seo->getMetaTitle()));
                         $this->_titlePage = false;
                     }
                     break;
                 case Mirasvit_Seo_Model_Config::META_TITLE_PAGE_NUMBER_END:
                     if ($page > 1) {
                         $seo->setMetaTitle(Mage::helper('seo')->__("%s | Page %s", $seo->getMetaTitle(), $page));
                         $this->_titlePage = false;
                     }
                     break;
                 case Mirasvit_Seo_Model_Config::META_TITLE_PAGE_NUMBER_BEGIN_FIRST_PAGE:
                     $seo->setMetaTitle(Mage::helper('seo')->__("Page %s | %s", $page, $seo->getMetaTitle()));
                     $this->_titlePage = false;
                     break;
                 case Mirasvit_Seo_Model_Config::META_TITLE_PAGE_NUMBER_END_FIRST_PAGE:
                     $seo->setMetaTitle(Mage::helper('seo')->__("%s | Page %s", $seo->getMetaTitle(), $page));
                     $this->_titlePage = false;
                     break;
             }
         }
         if ($this->_descriptionPage) {
             switch ($this->_config->getMetaDescriptionPageNumber($storeId)) {
                 case Mirasvit_Seo_Model_Config::META_DESCRIPTION_PAGE_NUMBER_BEGIN:
                     if ($page > 1) {
                         $seo->setMetaDescription(Mage::helper('seo')->__("Page %s | %s", $page, $seo->getMetaDescription()));
                         $this->_descriptionPage = false;
                     }
                     break;
                 case Mirasvit_Seo_Model_Config::META_DESCRIPTION_PAGE_NUMBER_END:
                     if ($page > 1) {
                         $seo->setMetaDescription(Mage::helper('seo')->__("%s | Page %s", $seo->getMetaDescription(), $page));
                         $this->_descriptionPage = false;
                     }
                     break;
                 case Mirasvit_Seo_Model_Config::META_DESCRIPTION_PAGE_NUMBER_BEGIN_FIRST_PAGE:
                     $seo->setMetaDescription(Mage::helper('seo')->__("Page %s | %s", $page, $seo->getMetaDescription()));
                     $this->_descriptionPage = false;
                     break;
                 case Mirasvit_Seo_Model_Config::META_DESCRIPTION_PAGE_NUMBER_END_FIRST_PAGE:
                     $seo->setMetaDescription(Mage::helper('seo')->__("%s | Page %s", $seo->getMetaDescription(), $page));
                     $this->_descriptionPage = false;
                     break;
             }
         }
         if ($page > 1) {
             $seo->setDescription('');
             //set an empty description for page with number > 1 (to not have a duplicate content)
         }
     }
     if ($metaTitleMaxLength = $this->_config->getMetaTitleMaxLength($storeId)) {
         $metaTitleMaxLength = (int) $metaTitleMaxLength;
         if ($metaTitleMaxLength < Mirasvit_Seo_Model_Config::META_TITLE_INCORRECT_LENGTH) {
             $metaTitleMaxLength = Mirasvit_Seo_Model_Config::META_TITLE_MAX_LENGTH;
             //recommended length
         }
         $seo->setMetaTitle($this->_getTruncatedString($seo->getMetaTitle(), $metaTitleMaxLength, $page));
     }
     if ($metaDescriptionMaxLength = $this->_config->getMetaDescriptionMaxLength($storeId)) {
         $metaDescriptionMaxLength = (int) $metaDescriptionMaxLength;
         if ($metaDescriptionMaxLength < Mirasvit_Seo_Model_Config::META_DESCRIPTION_INCORRECT_LENGTH) {
             $metaDescriptionMaxLength = Mirasvit_Seo_Model_Config::META_DESCRIPTION_MAX_LENGTH;
             //recommended length
         }
         $seo->setMetaDescription($this->_getTruncatedString($seo->getMetaDescription(), $metaDescriptionMaxLength, $page));
     }
     Mage::helper('mstcore/debug')->end($uid, $seo->getData());
     return $seo;
 }
Example #13
0
 /**
  * Convert xml object to a Varien object.
  *
  * @param SimpleXMLElement $xml Xml response from the API.
  * @return object Api response into a Varien object.
  */
 private function _mapTranscationDetails(SimpleXMLElement $xml)
 {
     $object = new Varien_Object();
     $object->setErrorcode($xml->errorcode);
     $object->setTimestamp($xml->timestamp);
     if ((string) $xml->errorcode === '0000') {
         $object->setVpstxid($xml->vpstxid);
         $object->setContactNumber($xml->contactnumber);
         $object->setVendortxcode($xml->vendortxcode);
         $object->setTransactiontype($xml->transactiontype);
         $object->setStatus($xml->status);
         $object->setDescription($xml->description);
         $object->setAmount($xml->amount);
         $object->setCurrency($xml->currency);
         $object->setStarted($xml->started);
         $object->setCompleted($xml->completed);
         $object->setSecuritykey($xml->securitykey);
         $object->setClientip($xml->clientip);
         $object->setIplocation($xml->iplocation);
         $object->setGiftaid($xml->giftaid);
         $object->setPaymentsystem($xml->paymentsystem);
         $object->setPaymentsystemdetails($xml->paymentsystemdetails);
         $object->setAuthprocessor($xml->authprocessor);
         $object->setMerchantnumber($xml->merchantnumber);
         $object->setAccounttype($xml->accounttype);
         $object->setBillingaddress($xml->billingaddress);
         $object->setBillingpostcode($xml->billingpostcode);
         $object->setDeliveryaddress($xml->deliveryaddress);
         $object->setDeliverypostcode($xml->deliverypostcode);
         $object->setSystemused($xml->systemused);
         $object->setCustomeremail($xml->customeremail);
         $object->setAborted($xml->aborted);
         $object->setRefunded($xml->refunded);
         $object->setRepeated($xml->repeated);
         $object->setBasket($xml->basket);
         $object->setApplyavscv2($xml->applyavscv2);
         $object->setApply3dsecure($xml->apply3dsecure);
         $object->setAttempt($xml->attempt);
         $object->setCardholder($xml->cardholder);
         $object->setCardaddress($xml->cardaddress);
         $object->setCardpostcode($xml->cardpostcode);
         $object->setStartdate($xml->startdate);
         $object->setExpirydate($xml->expirydate);
         $object->setLast4digits($xml->last4digits);
         $object->setThreedresult($xml->threedresult);
         $object->setEci($xml->eci);
         $object->setCavv($xml->cavv);
         $object->setT3mscore($xml->t3mscore);
         $object->setT3maction($xml->t3maction);
         $object->setT3mid($xml->t3mid);
     } else {
         $object->setError(htmlentities($xml->error));
     }
     return $object;
 }
Example #14
0
 /**
  * Return commno data for *all* transactions.
  * @return array Data
  */
 public function _getGeneralTrnData(Varien_Object $payment)
 {
     $order = $payment->getOrder();
     $quoteObj = $this->_getQuote();
     $vendorTxCode = $this->_getTrnVendorTxCode();
     if ($payment->getCcNumber()) {
         $vendorTxCode .= $this->_cleanString(substr($payment->getCcOwner(), 0, 10));
     }
     $payment->setVendorTxCode($vendorTxCode);
     $request = new Varien_Object();
     $request->setVPSProtocol('2.23')->setReferrerID($this->getConfigData('referrer_id'))->setVendor($this->getConfigData('vendor'))->setVendorTxCode($vendorTxCode);
     $request->setClientIPAddress($this->getClientIp());
     if ($payment->getIntegra()) {
         $this->getSageSuiteSession()->setLastVendorTxCode($vendorTxCode);
         $request->setIntegration($payment->getIntegra());
         $request->setData('notification_URL', $this->getNotificationUrl() . '&vtxc=' . $vendorTxCode);
         $request->setData('success_URL', $this->getSuccessUrl());
         $request->setData('redirect_URL', $this->getRedirectUrl());
         $request->setData('failure_URL', $this->getFailureUrl());
     }
     if ($this->_getIsAdminOrder()) {
         $request->setAccountType('M');
     }
     if ($payment->getAmountOrdered()) {
         $from = $order->getOrderCurrencyCode();
         if ((string) $this->getConfigData('trncurrency') == 'store') {
             $request->setAmount($this->formatAmount($quoteObj->getGrandTotal(), $quoteObj->getQuoteCurrencyCode()));
             $request->setCurrency($quoteObj->getQuoteCurrencyCode());
         } else {
             $request->setAmount($this->formatAmount($quoteObj->getBaseGrandTotal(), $quoteObj->getBaseCurrencyCode()));
             $request->setCurrency($quoteObj->getBaseCurrencyCode());
         }
     }
     if (!empty($order)) {
         $billing = $order->getBillingAddress();
         if (!empty($billing)) {
             $request->setBillingAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setBillingSurname($this->ss($billing->getLastname(), 20))->setBillingFirstnames($this->ss($billing->getFirstname(), 20))->setBillingPostCode($this->ss($billing->getPostcode(), 10))->setBillingAddress1($this->ss($billing->getStreet(1), 100))->setBillingAddress2($this->ss($billing->getStreet(2), 100))->setBillingCity($this->ss($billing->getCity(), 40))->setBillingCountry($billing->getCountry())->setContactNumber(substr($this->_cphone($billing->getTelephone()), 0, 20));
             if ($billing->getCountry() == 'US') {
                 $request->setBillingState($billing->getRegionCode());
             }
             $request->setCustomerEMail($billing->getEmail());
         }
         if (!$request->getDescription()) {
             $request->setDescription('.');
         }
         $shipping = $order->getShippingAddress();
         if (!empty($shipping)) {
             $request->setDeliveryAddress($shipping->getStreet(1) . ' ' . $shipping->getCity() . ' ' . $shipping->getRegion() . ' ' . $shipping->getCountry())->setDeliverySurname($this->ss($shipping->getLastname(), 20))->setDeliveryFirstnames($this->ss($shipping->getFirstname(), 20))->setDeliveryPostCode($this->ss($shipping->getPostcode(), 10))->setDeliveryAddress1($this->ss($shipping->getStreet(1), 100))->setDeliveryAddress2($this->ss($shipping->getStreet(2), 100))->setDeliveryCity($this->ss($shipping->getCity(), 40))->setDeliveryCountry($shipping->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($shipping->getTelephone())), 20));
             if ($shipping->getCountry() == 'US') {
                 $request->setDeliveryState($shipping->getRegionCode());
             }
         } else {
             #If the cart only has virtual products, I need to put an shipping address to Sage Pay.
             #Then the billing address will be the shipping address to
             $request->setDeliveryAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setDeliverySurname($this->ss($billing->getLastname(), 20))->setDeliveryFirstnames($this->ss($billing->getFirstname(), 20))->setDeliveryPostCode($this->ss($billing->getPostcode(), 10))->setDeliveryAddress1($this->ss($billing->getStreet(1), 100))->setDeliveryAddress2($this->ss($billing->getStreet(2), 100))->setDeliveryCity($this->ss($billing->getCity(), 40))->setDeliveryCountry($billing->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($billing->getTelephone())), 20));
             if ($billing->getCountry() == 'US') {
                 $request->setDeliveryState($billing->getRegionCode());
             }
         }
     }
     if ($payment->getCcNumber()) {
         $request->setCardNumber($payment->getCcNumber())->setExpiryDate(sprintf('%02d%02d', $payment->getCcExpMonth(), substr($payment->getCcExpYear(), strlen($payment->getCcExpYear()) - 2)))->setCardType($payment->getCcType())->setCV2($payment->getCcCid())->setCardHolder($payment->getCcOwner());
         if ($payment->getCcIssue()) {
             $request->setIssueNumber($payment->getCcIssue());
         }
         if ($payment->getCcStartMonth() && $payment->getCcStartYear()) {
             $request->setStartDate(sprintf('%02d%02d', $payment->getCcStartMonth(), substr($payment->getCcStartYear(), strlen($payment->getCcStartYear()) - 2)));
         }
     }
     $totals = $shipping->getTotals();
     $shippingTotal = isset($totals['shipping']) ? $totals['shipping']->getValue() : 0;
     if ($this->getSendBasket()) {
         $request->setBasket($this->_getBasketContents($quoteObj));
     }
     if (!$request->getDeliveryPostCode()) {
         $request->setDeliveryPostCode('000');
     }
     if (!$request->getBillingPostCode()) {
         $request->setBillingPostCode('000');
     }
     return $request;
 }
Example #15
0
 public function writeTempFile($curr_page = 0, $length = 50, $filename = '')
 {
     $products = $this->getFeed()->getProductsCollection('', $curr_page, $length);
     $stock_collection = Mage::getResourceModel('cataloginventory/stock_item_collection');
     $content = file_get_contents($this->getFeed()->getDirPath() . '/feed-' . $this->getFeed()->getId() . '-xml-product-block-template.tmp');
     $fp = fopen($this->getFeed()->getTempFilePath(), 'a');
     $log_fp = fopen(sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), 'log-' . $this->getFeed()->getId() . '.txt'), 'a');
     $log_content = date("F j, Y, g:i:s a") . ', page:' . $curr_page . ', items selected:' . count($products) . "\n";
     fwrite($log_fp, $log_content);
     fclose($log_fp);
     $store = Mage::getModel('core/store')->load($this->getFeed()->getStoreId());
     $root_category = Mage::getModel('catalog/category')->load($store->getRootCategoryId());
     if (Mage::getStoreConfig('gomage_feedpro/imagesettings/enable')) {
         $image_width = intval(Mage::getStoreConfig('gomage_feedpro/imagesettings/width'));
         $image_height = intval(Mage::getStoreConfig('gomage_feedpro/imagesettings/height'));
     } else {
         $image_width = 0;
         $image_height = 0;
     }
     foreach ($products as $_product) {
         $category_path = array();
         $category = null;
         foreach ($_product->getCategoryIds() as $id) {
             $_category = $this->getFeed()->getCategoriesCollection()->getItemById($id);
             if (is_null($category) || $category && $_category && $category->getLevel() < $_category->getLevel()) {
                 $category = $_category;
             }
         }
         if ($category) {
             $category_path = array($category->getName());
             $parent_id = $category->getParentId();
             if ($category->getLevel() > $root_category->getLevel()) {
                 while ($_category = $this->getFeed()->getCategoriesCollection()->getItemById($parent_id)) {
                     if ($_category->getLevel() <= $root_category->getLevel()) {
                         break;
                     }
                     $category_path[] = $_category->getName();
                     $parent_id = $_category->getParentId();
                 }
             }
         }
         $product = new Varien_Object();
         if ($category) {
             $product->setCategory($category->getName());
             $product->setCategoryId($category->getEntityId());
             $product->setCategorySubcategory(implode(' -&gt; ', array_reverse($category_path)));
         } else {
             $product->setCategory('');
             $product->setCategorySubcategory('');
         }
         $template_attributes = $this->getAllVars($content);
         $custom_attributes = Mage::getResourceModel('gomage_feed/custom_attribute_collection');
         $custom_attributes->load();
         foreach ($template_attributes as $attribute_code) {
             $value = null;
             switch ($attribute_code) {
                 case 'parent_sku':
                     if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                         $value = $parent_product->getSku();
                     } else {
                         $value = '';
                     }
                     break;
                 case 'parent_base_image':
                     if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                         $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
                     } else {
                         $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                     }
                     try {
                         if ($image_width || $image_height) {
                             $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                         } else {
                             $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                         }
                     } catch (Exception $e) {
                         $image_url = '';
                     }
                     $value = $image_url;
                     break;
                 case 'price':
                     if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
                         $value = $store->convertPrice($_product->getMinimalPrice(), false, false);
                     } else {
                         $value = $store->convertPrice($_product->getPrice(), false, false);
                     }
                     break;
                 case 'store_price':
                 case 'final_price':
                     $value = $store->convertPrice($_product->getFinalPrice(), false, false);
                     break;
                 case 'image':
                 case 'gallery':
                 case 'media_gallery':
                     $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                     try {
                         if ($image_width || $image_height) {
                             $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                         } else {
                             $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                         }
                     } catch (Exception $e) {
                         $image_url = '';
                     }
                     $product->setData($attribute_code, $image_url);
                     break;
                 case 'image_2':
                 case 'image_3':
                 case 'image_4':
                 case 'image_5':
                     if (!$_product->hasData('media_gallery_images')) {
                         $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                         $_product->setData('media_gallery_images', $_prod->getMediaGalleryImages());
                     }
                     $i = 0;
                     foreach ($_product->getMediaGalleryImages() as $_image) {
                         $i++;
                         if ('image_' . $i == $attribute_code) {
                             if ($image_width || $image_height) {
                                 $product->setData($attribute_code, (string) Mage::helper('catalog/image')->init($_product, 'image', $_image->getFile())->resize($image_width, $image_height));
                             } else {
                                 $product->setData($attribute_code, $_image['url']);
                             }
                         }
                     }
                     break;
                 case 'parent_url':
                     if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                         $product->setParentUrl($parent_product->getProductUrl(false));
                         break;
                     }
                     $product->setParentUrl($_product->getProductUrl(false));
                     break;
                 case 'url':
                     $product->setUrl($_product->getProductUrl(false));
                     break;
                 default:
                     if (strpos($attribute_code, 'custom:') === 0) {
                         $custom_code = trim(str_replace('custom:', '', $attribute_code));
                         if ($custom_attribute = $custom_attributes->getItemByColumnValue('code', $custom_code)) {
                             $options = Zend_Json::decode($custom_attribute->getData('data'));
                             foreach ($options as $option) {
                                 foreach ($option['condition'] as $condition) {
                                     switch ($condition['attribute_code']) {
                                         case 'product_type':
                                             $attr_value = $_product->getTypeId();
                                             break;
                                         case 'price':
                                             if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
                                                 $attr_value = $store->convertPrice($_product->getMinimalPrice(), false, false);
                                             } else {
                                                 $attr_value = $store->convertPrice($_product->getPrice(), false, false);
                                             }
                                             break;
                                         case 'store_price':
                                             $attr_value = $store->convertPrice($_product->getFinalPrice(), false, false);
                                             break;
                                         case 'parent_url':
                                             if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                                                 $attr_value = $parent_product->getProductUrl(false);
                                                 break;
                                             }
                                             $attr_value = $_product->getProductUrl(false);
                                             break;
                                         case 'image':
                                         case 'gallery':
                                         case 'media_gallery':
                                             if (!$_product->hasData('product_base_image')) {
                                                 $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                                                 try {
                                                     if ($image_width || $image_height) {
                                                         $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                                                     } else {
                                                         $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                                                     }
                                                 } catch (Exception $e) {
                                                     $image_url = '';
                                                 }
                                                 $_product->setData('product_base_image', $image_url);
                                                 $attr_value = $image_url;
                                             } else {
                                                 $attr_value = $_product->getData('product_base_image');
                                             }
                                             break;
                                         case 'url':
                                             $attr_value = $_product->getProductUrl(false);
                                             break;
                                         case 'qty':
                                             if ($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())) {
                                                 $attr_value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
                                             } else {
                                                 $attr_value = 0;
                                             }
                                             break;
                                         case 'is_in_stock':
                                             $attr_value = ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getIsInStock());
                                             if (!$attr_value || $attr_value == '' || $attr_value == null) {
                                                 $attr_value = 0;
                                             }
                                             //								            if($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())){
                                             //
                                             //            									$attr_value = $stock_collection->getItemByColumnValue('product_id', $_product->getId())->getData('is_in_stock');
                                             //
                                             //            								}else{
                                             //
                                             //            									$attr_value = 0;
                                             //
                                             //            								}
                                             break;
                                         case 'category':
                                             $attr_value = $product->getCategory();
                                             break;
                                         case 'category_id':
                                             $attr_value = $_product->getCategoryIds();
                                             break;
                                         default:
                                             $attr_value = $_product->getData($condition['attribute_code']);
                                     }
                                     $cond_value = $condition['value'];
                                     $is_multi = false;
                                     if ($product_attribute = $_product->getResource()->getAttribute($condition['attribute_code'])) {
                                         if ($product_attribute->getFrontendInput() == 'multiselect') {
                                             $is_multi = true;
                                             $attr_value = explode(',', $attr_value);
                                         }
                                     }
                                     if ($condition['attribute_code'] == 'category_id') {
                                         $is_multi = true;
                                     }
                                     switch ($condition['condition']) {
                                         case 'eq':
                                             if (!$is_multi && $attr_value == $cond_value || $is_multi && in_array($cond_value, $attr_value)) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'neq':
                                             if (!$is_multi && $attr_value != $cond_value || $is_multi && !in_array($cond_value, $attr_value)) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'gt':
                                             if ($attr_value > $cond_value) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'lt':
                                             if ($attr_value < $cond_value) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'gteq':
                                             if ($attr_value >= $cond_value) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'lteq':
                                             if ($attr_value <= $cond_value) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'like':
                                             if (strpos($attr_value, $cond_value) !== false) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'nlike':
                                             if (strpos($attr_value, $cond_value) === false) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                     }
                                 }
                                 if (in_array($option['value_type'], array('percent', 'attribute'))) {
                                     switch ($option['value_type_attribute']) {
                                         case 'price':
                                             if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
                                                 $attribute_value = $store->convertPrice($_product->getMinimalPrice(), false, false);
                                             } else {
                                                 $attribute_value = $store->convertPrice($_product->getPrice(), false, false);
                                             }
                                             break;
                                         case 'store_price':
                                             $attribute_value = $store->convertPrice($_product->getFinalPrice(), false, false);
                                             break;
                                         case 'parent_url':
                                             if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                                                 $attribute_value = $parent_product->getProductUrl(false);
                                                 break;
                                             }
                                             $attribute_value = $_product->getProductUrl(false);
                                             break;
                                         case 'image':
                                         case 'gallery':
                                         case 'media_gallery':
                                             if (!$_product->hasData('product_base_image')) {
                                                 $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                                                 try {
                                                     if ($image_width || $image_height) {
                                                         $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                                                     } else {
                                                         $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                                                     }
                                                 } catch (Exception $e) {
                                                     $image_url = '';
                                                 }
                                                 $_product->setData('product_base_image', $image_url);
                                                 $attribute_value = $image_url;
                                             } else {
                                                 $attribute_value = $_product->getData('product_base_image');
                                             }
                                             break;
                                         case 'url':
                                             $attribute_value = $_product->getProductUrl(false);
                                             break;
                                         case 'qty':
                                             $attribute_value = ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());
                                             if (!$attribute_value || $attribute_value == '' || $attribute_value == null) {
                                                 $attribute_value = 0;
                                             }
                                             //	        								if($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())){
                                             //
                                             //	        									$attribute_value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
                                             //
                                             //	        								}else{
                                             //
                                             //	        									$attribute_value = 0;
                                             //
                                             //	        								}
                                             break;
                                         case 'category':
                                             $attribute_value = $product->getCategory();
                                             break;
                                         default:
                                             $attribute_value = $_product->getData($option['value_type_attribute']);
                                     }
                                 }
                                 if ($option['value_type'] == 'percent') {
                                     $value = floatval($attribute_value) / 100 * floatval($option['value']);
                                 } elseif ($option['value_type'] == 'attribute') {
                                     $value = $attribute_value;
                                 } else {
                                     $value = $option['value'];
                                 }
                                 break;
                             }
                             if ($value === null && $custom_attribute->getDefaultValue()) {
                                 switch ($custom_attribute->getDefaultValue()) {
                                     case 'price':
                                         if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
                                             $value = $store->convertPrice($_product->getMinimalPrice(), false, false);
                                         } else {
                                             $value = $store->convertPrice($_product->getPrice(), false, false);
                                         }
                                         break;
                                     case 'store_price':
                                         $value = $store->convertPrice($_product->getFinalPrice(), false, false);
                                         break;
                                     case 'parent_url':
                                         if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                                             $value = $parent_product->getProductUrl(false);
                                             break;
                                         }
                                         $value = $_product->getProductUrl(false);
                                         break;
                                     case 'image':
                                     case 'gallery':
                                     case 'media_gallery':
                                         if (!$_product->hasData('product_base_image')) {
                                             $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                                             try {
                                                 if ($image_width || $image_height) {
                                                     $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                                                 } else {
                                                     $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                                                 }
                                             } catch (Exception $e) {
                                                 $image_url = '';
                                             }
                                             $_product->setData('product_base_image', $image_url);
                                             $value = $image_url;
                                         } else {
                                             $value = $_product->getData('product_base_image');
                                         }
                                         break;
                                     case 'url':
                                         $value = $_product->getProductUrl(false);
                                         break;
                                     case 'qty':
                                         $value = ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());
                                         if (!$value || $value == '' || $value == null) {
                                             $value = 0;
                                         }
                                         //        								if($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())){
                                         //
                                         //        									$value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
                                         //
                                         //        								}else{
                                         //
                                         //        									$value = 0;
                                         //
                                         //        								}
                                         break;
                                     case 'category':
                                         $value = $product->getCategory();
                                         break;
                                     default:
                                         $value = $_product->getData($custom_attribute->getDefaultValue());
                                 }
                             }
                         }
                     } elseif ($attribute_model = $_product->getResource()->getAttribute($attribute_code)) {
                         switch ($attribute_model->getFrontendInput()) {
                             case 'select':
                             case 'multiselect':
                                 $value = implode(', ', (array) $_product->getAttributeText($attribute_code));
                                 break;
                             default:
                                 $value = $_product->getData($attribute_code);
                                 break;
                         }
                     }
                     break;
             }
             if ($value && !$product->getData($attribute_code)) {
                 $product->setData($attribute_code, $value);
             }
         }
         $product->setDescription(strip_tags(preg_replace('/<br.*?>/s', "\r\n", $_product->getDescription())));
         $product->setShortDescription(strip_tags(preg_replace('/<br.*?>/s', "\r\n", $_product->getShortDescription())));
         $product->setQty(ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()));
         fwrite($fp, parent::setVars($content, $product) . "\r\n");
     }
     fclose($fp);
 }
Example #16
0
 public function prepareShippingObj($params)
 {
     $method = $params['shipping_method_radio'];
     $shipping = new Varien_Object();
     $shipping->setDescription($params['s_description'][$method])->setAmount($params['s_amount_excl_tax'][$method])->setAmountInclTax($params['s_amount_incl_tax'][$method])->setMethod($method);
     return $shipping;
 }