public function testGetTokenInfo()
 {
     $payment = new Varien_Object();
     $payment->setCcCid('789');
     $vaultCard = new Varien_Object();
     $vaultCard->setCcType('VI');
     $vaultCard->setLast4('1234');
     $vaultCard->setType('VI');
     $vaultCard->setExpirationMonth('12');
     $vaultCard->setExpirationYear('2050');
     $vaultCard->setToken('1111222233331234');
     $litle = new Litle_CreditCard_Model_PaymentLogic();
     $modelPalorusVault = $this->getMock('Litle_Palorus_Model_Vault');
     $modelPalorusVault->expects($this->any())->method('load')->with($this->equalTo(50))->will($this->returnValue($vaultCard));
     $litle->setModelPalorusVault($modelPalorusVault);
     $info = new Mage_Payment_Model_Info();
     $info->setAdditionalInformation('cc_vaulted', 50);
     $arr = array('info_instance' => $info);
     $litle->addData($arr);
     $tokenInfo = $litle->getTokenInfo($payment);
     $this->assertEquals('1234', $payment->getCcLast4());
     $this->assertEquals('VI', $payment->getCcType());
     $this->assertEquals('789', $tokenInfo['cardValidationNum']);
     $this->assertEquals('VI', $tokenInfo['type']);
     $this->assertEquals('1111222233331234', $tokenInfo['litleToken']);
     $this->assertEquals('1250', $tokenInfo['expDate']);
 }
Example #2
0
 protected function _loadXmlElementCustomParams($element)
 {
     $params = array();
     $sortOrder = 0;
     foreach ($element->asCanonicalArray() as $key => $data) {
         if (is_array($data)) {
             $data['sort_order'] = isset($data['sort_order']) ? (int) $data['sort_order'] : 'top';
             // 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;
             }
             $params[$key] = $data;
             $sortOrder++;
         }
     }
     return $params;
 }
Example #3
0
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     if (Mage::registry('gomage_feed')) {
         $item = Mage::registry('gomage_feed');
     } else {
         $item = new Varien_Object();
     }
     $this->setForm($form);
     $fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Item information')));
     $headerBar = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('label' => Mage::helper('catalog')->__('Feed Pro Help'), 'class' => 'go', 'id' => 'feed_pro_help', 'onclick' => 'window.open(\'http://www.gomage.com/faq/extensions/feed-pro\')'));
     $fieldset->setHeaderBar($headerBar->toHtml());
     $fieldset->addField('type', 'hidden', array('name' => 'type'));
     $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true, 'note' => $this->__('e.g. "Google Base", "Yahoo! Store"...')));
     if ($item->getId() && ($url = $item->getUrl())) {
         $fieldset->addField('comments', 'note', array('label' => $this->__('Access Url'), 'title' => $this->__('Access Url'), 'text' => '<a href="' . $url . '" target="_blank">' . $url . '</a>'));
     }
     $fieldset->addField('filename', 'text', array('name' => 'filename', 'label' => $this->__('Filename'), 'title' => $this->__('Filename'), 'required' => false, 'note' => $this->__('e.g. "productfeed.csv", "productfeed.xml"...')));
     $fieldset->addField('store_id', 'select', array('label' => $this->__('Store View'), 'required' => true, 'name' => 'store_id', 'values' => Mage::getModel('gomage_feed/adminhtml_system_config_source_store')->getStoreValuesForForm()));
     if (!$item->getType() && $this->getRequest()->getParam('type')) {
         $item->setType($this->getRequest()->getParam('type'));
     }
     $form->setValues($item->getData());
     return parent::_prepareForm();
 }
Example #4
0
 /**
  * Return the PayPal payment type
  *
  * @return mixed
  */
 public function getPaymentType()
 {
     $object = new Varien_Object();
     $object->setType($this->_getConfig('payment_type'));
     // Specific event for this method
     Mage::dispatchEvent('gene_paypal_get_payment_type', array('object' => $object));
     return $object->getType();
 }
 /**
  * Creates a new report.
  *
  * @return Varien_Object
  */
 protected function _createReport()
 {
     $report = new Varien_Object();
     $report->setType($this->_getType());
     $report->setEntityType($this->_getEntity());
     $report->setFailures(0);
     $report->setSuccesses(0);
     $report->setDuplicates(0);
     return $report;
 }
Example #6
0
 protected function _getRewritesArray()
 {
     $rewritesArray = array();
     foreach ($this->getTypes() as $type => $label) {
         $rewrites = $this->_collectRewrites($type);
         foreach ($rewrites as $initialClass => $rewritesData) {
             $rewriteItem = new Varien_Object();
             $rewriteItem->setClass($initialClass);
             $rewriteItem->setType($type);
             $rewriteItem->setRewrites($rewritesData);
             $rewriteItem->setConflict($this->_getConflict($rewritesData['classes']));
             $rewritesArray[] = $rewriteItem;
         }
     }
     return $rewritesArray;
 }
Example #7
0
 public function getAsyncCollection()
 {
     $this->getSavedTime();
     $result = array();
     $processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
     $eventsCollection = Mage::getResourceModel('index/event_collection');
     $eventsCollection->addProcessFilter($processes->getAllIds(), Mage_Index_Model_Process::EVENT_STATUS_NEW);
     $eventsCollection->getSelect()->group('entity')->group('entity_pk');
     $this->setQueueSize($eventsCollection->count());
     foreach ($eventsCollection as $event) {
         $item = new Varien_Object();
         $item->setType($event->getType());
         $item->setEntity($event->getEntity());
         $item->setEntityPk($event->getEntityPk());
         $result[] = $item;
         if (count($result) > 10) {
             break;
         }
     }
     return $result;
 }
Example #8
0
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     if (Mage::registry('ranvi_feed')) {
         $item = Mage::registry('ranvi_feed');
     } else {
         $item = new Varien_Object();
     }
     $this->setForm($form);
     $fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Item information')));
     $fieldset->addField('type', 'hidden', array('name' => 'type'));
     $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true));
     if ($item->getId() && ($url = $item->getUrl())) {
         $fieldset->addField('comments', 'note', array('label' => $this->__('Access Url'), 'title' => $this->__('Access Url'), 'text' => '<a href="' . $url . '" target="_blank">' . $url . '</a>'));
     }
     $fieldset->addField('filename', 'text', array('name' => 'filename', 'label' => $this->__('Filename'), 'title' => $this->__('Filename'), 'required' => false));
     $fieldset->addField('store_id', 'select', array('label' => $this->__('Store View'), 'required' => true, 'name' => 'store_id', 'values' => Mage::getModel('ranvi_feed/adminhtml_system_config_source_store')->getStoreValuesForForm()));
     if (!$item->getType() && $this->getRequest()->getParam('type')) {
         $item->setType($this->getRequest()->getParam('type'));
     }
     $form->setValues($item->getData());
     return parent::_prepareForm();
 }
Example #9
0
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     if (Mage::registry('gomage_custom_attribute')) {
         $item = Mage::registry('gomage_custom_attribute');
     } else {
         $item = new Varien_Object();
     }
     $this->setForm($form);
     $fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Attribute Information')));
     $fieldset->addField('type', 'hidden', array('name' => 'type'));
     $headerBar = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('label' => Mage::helper('catalog')->__('Feed Pro Help'), 'class' => 'go', 'id' => 'feed_pro_help', 'onclick' => 'window.open(\'http://www.gomage.com/faq/extensions/feed-pro\')'));
     $fieldset->setHeaderBar($headerBar->toHtml());
     $fieldset->addField('code', 'text', array('name' => 'code', 'label' => $this->__('Dynamic Attribute Code'), 'title' => $this->__('Dynamic Attribute Code'), 'required' => true, 'class' => 'validate-code', 'note' => $this->__('For internal use. Must be unique with no spaces')));
     $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true, 'note' => $this->__('e.g. "Custom Price", "Google Category"...')));
     if (!$item->getType() && $this->getRequest()->getParam('type')) {
         $item->setType($this->getRequest()->getParam('type'));
     }
     if ($item->getId()) {
         $form->setValues($item->getData());
     }
     return parent::_prepareForm();
 }
 /**
  * Submit prompt action
  *
  * @return  string
  */
 public function promptAction()
 {
     $params = $this->getRequest()->getParams();
     $response = new Varien_Object();
     try {
         $key = $params['id'];
         $data = $params['data'];
         if (empty($key) || empty($data)) {
             Mage::throwException('Parameters key and data are required');
         }
         if (!($prompt = $this->_loadPrompt($key))) {
             Mage::throwException('Session time out, try again');
         }
         $request = $this->_getRequestModel()->setRequest($prompt)->dispatch($data);
         $response->setStatus('OK');
         $response->setMessage($request->getMessage());
         $response->setType(MageHack_MageConsole_Model_Abstract::RESPONSE_TYPE_MESSAGE);
     } catch (Exception $e) {
         $response->setStatus('ERROR');
         $response->setType(MageHack_MageConsole_Model_Abstract::RESPONSE_TYPE_ERROR);
         $response->setMessage($e->getMessage());
     }
     $this->getResponse()->setHeader('Content-Type', 'application/json', true)->setBody($response->toJson());
 }
Example #11
0
 /**
  * Returns Google Base recommended Item Types
  *
  * @param string $targetCountry Two-letters country ISO code
  * @return array
  */
 public function getItemTypes($targetCountry)
 {
     $locale = Mage::getSingleton('googlebase/config')->getCountryInfo($targetCountry, 'locale');
     $location = self::ITEM_TYPES_LOCATION . '/' . $locale;
     $itemTypes = array();
     foreach ($this->getGuestService()->getFeed($location)->entries as $entry) {
         if (isset($entry->extensionElements[1])) {
             // has attributes node?
             $typeAttributes = $entry->extensionElements[1]->extensionElements;
             if (is_array($typeAttributes) && !empty($typeAttributes)) {
                 // only items with attributes allowed
                 $type = $entry->extensionElements[0]->text;
                 $item = new Varien_Object();
                 $item->setId($type);
                 $item->setName($entry->title->text);
                 $item->setLocation($entry->id->text);
                 $itemTypes[$type] = $item;
                 $attributes = array();
                 foreach ($typeAttributes as $attr) {
                     $name = $attr->extensionAttributes['name']['value'];
                     $type = $attr->extensionAttributes['type']['value'];
                     $attribute = new Varien_Object();
                     $attribute->setId($name);
                     $attribute->setName($name);
                     $attribute->setType($type);
                     $attributes[$name] = $attribute;
                 }
                 ksort($attributes);
                 $item->setAttributes($attributes);
             }
         }
     }
     ksort($itemTypes);
     $this->_itemTypes = $itemTypes;
     return $itemTypes;
 }
Example #12
0
 /**
  * Return widget XML configuration as Varien_Object and makes some data preparations
  *
  * @param string $type Widget type
  * @return Varien_Object
  */
 public function getConfigAsObject($type)
 {
     $xml = $this->getConfigAsXml($type);
     $object = new Varien_Object();
     if ($xml === null) {
         return $object;
     }
     // Save all nodes to object data
     $object->setType($type);
     $object->setData($xml->asCanonicalArray());
     // Set module for translations etc.
     $module = $object->getData('@/module');
     if ($module) {
         $object->setModule($module);
     }
     // Correct widget parameters and convert its data to objects
     $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 drop-dawns) 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;
 }
 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;
 }
 public function getOptionValues()
 {
     $data = array();
     $optionsArr = '';
     $data = $this->getTemplateData();
     if (isset($data['hash_options'])) {
         $optionsArr = $data['hash_options'];
     }
     $zendDate = new Zend_Date();
     $dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
     $helper = Mage::helper('customoptions');
     $helper->getCustomerGroups();
     // init customer_groups for sort prices
     $groupId = (int) $this->getRequest()->getParam('group_id');
     if ($optionsArr) {
         $optionsArr = unserialize($optionsArr);
     }
     $store = Mage::app()->getStore($this->getStoreId());
     $storeOptionsArr = array();
     $groupStore = Mage::getSingleton('customoptions/group_store')->loadByGroupAndStore($groupId, $this->getStoreId());
     if ($groupStore->getHashOptions()) {
         $storeOptionsArr = unserialize($groupStore->getHashOptions());
     }
     //print_r($storeOptionsArr); exit;
     $optionModel = Mage::getSingleton('catalog/product_option');
     if (!$this->_values && $optionsArr) {
         $values = array();
         $sortOrder = array();
         $scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE);
         $optionItemCount = count($optionsArr);
         foreach ($optionsArr as $optionId => $option) {
             $option = new Varien_Object($option);
             $value = array();
             if ($option->getIsDelete() != '1') {
                 $value['id'] = $option->getOptionId();
                 $value['item_count'] = $optionItemCount;
                 $value['option_id'] = $option->getOptionId();
                 $value['title'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['title']) ? $storeOptionsArr[$optionId]['title'] : $option->getTitle());
                 // old view_mode = hidden => to new type = 'hidden';
                 if ($optionModel->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT && $option->getViewMode() == 2) {
                     $option->setType('hidden');
                     $option->setViewMode(1);
                 }
                 $value['type'] = $option->getType();
                 $value['is_require'] = $option->getIsRequire();
                 $value['view_mode'] = isset($storeOptionsArr[$optionId]['view_mode']) ? $storeOptionsArr[$optionId]['view_mode'] : $option->getViewMode();
                 $value['is_dependent'] = $option->getIsDependent();
                 $value['div_class'] = $option->getDivClass();
                 $value['sku_policy'] = $option->getSkuPolicy();
                 $value['customoptions_is_onetime'] = $option->getCustomoptionsIsOnetime();
                 $value['qnty_input'] = $option->getQntyInput() ? 'checked' : '';
                 $value['qnty_input_disabled'] = $option->getType() == 'multiple' || $option->getType() == 'hidden' ? 'disabled' : '';
                 $value['image_mode'] = $option->getImageMode();
                 $value['image_mode_disabled'] = $optionModel->getGroupByType($option->getType()) != Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT ? 'disabled' : '';
                 $value['exclude_first_image'] = $option->getExcludeFirstImage() ? 'checked' : '';
                 $value['description'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['description']) ? $storeOptionsArr[$optionId]['description'] : $option->getDescription());
                 if ($helper->isCustomerGroupsEnabled() && $option->getCustomerGroups() != null) {
                     $value['customer_groups'] = implode(',', $option->getCustomerGroups());
                 }
                 if ($helper->isStoreViewsEnabled() && $option->getStoreViews() != null) {
                     $value['store_views'] = implode(',', $option->getStoreViews());
                 }
                 $value['in_group_id'] = $option->getInGroupId();
                 $value['in_group_id_view'] = $option->getInGroupId();
                 $value['sort_order'] = $this->_getSortOrder($option);
                 if ($this->getStoreId() != '0') {
                     $value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['title']));
                     $value['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['title']) ? 'disabled' : null;
                     $value['checkboxScopeViewMode'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'view_mode', !isset($storeOptionsArr[$optionId]['view_mode']));
                     $value['scopeViewModeDisabled'] = !isset($storeOptionsArr[$optionId]['view_mode']) ? 'disabled' : null;
                     $value['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['description']));
                     $value['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['description']) ? 'disabled' : null;
                 }
                 if ($optionModel->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
                     $countValues = count($option->getValues());
                     if ($countValues > 0) {
                         foreach ($option->getValues() as $key => $_value) {
                             $_value = new Varien_Object($_value);
                             $_value->setOptionTypeId($key);
                             if ($_value->getIsDelete() != '1') {
                                 $defaultArray = $option->getDefault() !== null ? $option->getDefault() : array();
                                 if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'])) {
                                     $_value->setPrice(floatval($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price']));
                                 }
                                 if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type'])) {
                                     $_value->setPriceType($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type']);
                                 }
                                 // for support old format:
                                 if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_price'])) {
                                     $_value->setSpecialPrice(floatval($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_price']));
                                 }
                                 if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_comment'])) {
                                     $_value->setSpecialComment($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_comment']);
                                 }
                                 if ($_value->getSpecialPrice()) {
                                     $_value->setSpecials(array(array('customer_group_id' => 32000, 'price' => $_value->getSpecialPrice(), 'price_type' => 'fixed', 'comment' => $_value->getSpecialComment(), 'date_from' => '', 'date_to' => '')));
                                 }
                                 $helper->applyLinkedBySkuDataToOption($_value, $_value->getSku(), $store, 0);
                                 $helper->calculateOptionSpecialPrice($_value, null, $helper->isSpecialPriceEnabled());
                                 $priceDisabled = $_value->getIsSkuPrice();
                                 list($skuClass, $viewProductBySkuHtml) = $this->getViewSkuData($_value->getSku());
                                 if (!$helper->isSkuQtyLinkingEnabled() || $helper->getProductIdBySku($_value->getSku()) == 0) {
                                     $customoptionsQty = $_value->getCustomoptionsQty();
                                 } else {
                                     list($customoptionsQty, $backorders) = $helper->getCustomoptionsQty($_value->getCustomoptionsQty(), $_value->getSku(), 0, null, null, null, true);
                                 }
                                 $value['optionValues'][$key] = array('item_count' => $countValues, 'option_id' => $option->getOptionId(), 'option_type_id' => $_value->getOptionTypeId(), 'title' => $this->htmlEscape(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title'] : $_value->getTitle()), 'price' => $this->getPriceValue($_value->getPrice(), $_value->getPriceType()), 'price_type' => $_value->getPriceType(), 'price_disabled' => $priceDisabled, 'description' => $this->htmlEscape(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description'] : $_value->getDescription()), 'cost' => $this->getPriceValue($_value->getCost(), 'fixed'), 'cost_disabled' => $_value->getIsSkuCost() ? 'disabled' : '', 'customoptions_qty' => $customoptionsQty, 'customoptions_qty_disabled' => $helper->isSkuQtyLinkingEnabled() && $helper->getProductIdBySku($_value->getSku()) ? 'disabled="disabled"' : '', 'sku' => $this->htmlEscape($_value->getSku()), 'sku_class' => $skuClass, 'view_product_by_sku_html' => $viewProductBySkuHtml, 'image_button_label' => $helper->__('Add Image'), 'sort_order' => $this->_getSortOrder($_value), 'checked' => array_search($_value->getOptionTypeId(), $defaultArray) !== false ? 'checked' : '', 'default_type' => $option->getType() == 'checkbox' || $option->getType() == 'multiple' || $option->getType() == 'multiswatch' || $option->getType() == 'hidden' ? 'checkbox' : 'radio', 'in_group_id' => $_value->getInGroupId(), 'in_group_id_view' => $_value->getInGroupId(), 'dependent_ids' => $_value->getDependentIds(), 'weight' => number_format(floatval($_value->getWeight()), 4, null, ''), 'weight_disabled' => $_value->getIsSkuWeight() ? 'disabled' : '');
                                 // getImages
                                 $images = $_value->getImages();
                                 if ($images) {
                                     $imagePath = $groupId . DS . $option->getId() . DS . $_value->getOptionTypeId() . DS;
                                     foreach ($images as $fileName) {
                                         if (substr($fileName, 0, 1) == '#') {
                                             // color
                                             $colorArr = array('id' => $option->getId(), 'select_id' => $_value->getOptionTypeId(), 'image_file' => $fileName, 'option_type_image_id' => $fileName, 'source' => 2);
                                             $value['optionValues'][$key]['images'][] = $colorArr;
                                         } else {
                                             // file
                                             $imgArr = $helper->getImgData($imagePath . $fileName, $option->getId(), $_value->getOptionTypeId());
                                             if ($imgArr) {
                                                 $imgArr['option_type_image_id'] = $imgArr['file_name'];
                                                 $value['optionValues'][$key]['images'][] = $imgArr;
                                             }
                                         }
                                     }
                                 } elseif ($_value->getImagePath()) {
                                     // old format
                                     $imgArr = $helper->getImgData($_value->getImagePath(), $option->getId(), $_value->getOptionTypeId());
                                     if ($imgArr) {
                                         $imgArr['option_type_image_id'] = $imgArr['file_name'];
                                         $value['optionValues'][$key]['images'][] = $imgArr;
                                     }
                                 } else {
                                     $value['optionValues'][$key]['image_tr_style'] = 'display:none';
                                 }
                                 //getOptionValueSpecialPrices
                                 $specialPrices = isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['specials']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['specials'] : $_value->getSpecials();
                                 if ($specialPrices) {
                                     foreach ($specialPrices as $specialKey => $specialPrice) {
                                         $specialPrices[$specialKey]['price'] = $this->getPriceValue($specialPrice['price'], $specialPrice['price_type']);
                                         if (isset($specialPrice['date_from']) && $specialPrice['date_from']) {
                                             $specialPrices[$specialKey]['date_from'] = $zendDate->setDate($specialPrice['date_from'], Varien_Date::DATE_INTERNAL_FORMAT)->toString($dateFormat);
                                         } else {
                                             $specialPrices[$specialKey]['date_from'] = '';
                                         }
                                         if (isset($specialPrice['date_to']) && $specialPrice['date_to']) {
                                             $specialPrices[$specialKey]['date_to'] = $zendDate->setDate($specialPrice['date_to'], Varien_Date::DATE_INTERNAL_FORMAT)->toString($dateFormat);
                                         } else {
                                             $specialPrices[$specialKey]['date_to'] = '';
                                         }
                                     }
                                     usort($specialPrices, array($helper, '_sortPrices'));
                                     $value['optionValues'][$key]['specials'] = $specialPrices;
                                 }
                                 //getOptionValueTierPrices
                                 $tierPrices = isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['tiers']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['tiers'] : $_value->getTiers();
                                 if ($tierPrices) {
                                     foreach ($tierPrices as $tierKey => $tierPrice) {
                                         $tierPrices[$tierKey]['price'] = $this->getPriceValue($tierPrice['price'], $tierPrice['price_type']);
                                     }
                                     usort($tierPrices, array($helper, '_sortPrices'));
                                     $value['optionValues'][$key]['tiers'] = $tierPrices;
                                 }
                                 if ($this->getStoreId() != '0') {
                                     $value['optionValues'][$key]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']), $_value->getOptionTypeId());
                                     $value['optionValues'][$key]['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? 'disabled' : null;
                                     $value['optionValues'][$key]['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description']), $_value->getOptionTypeId());
                                     $value['optionValues'][$key]['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description']) ? 'disabled' : null;
                                     //if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
                                     if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'])) {
                                         $scopePrice = true;
                                     } else {
                                         $scopePrice = false;
                                     }
                                     if (!$priceDisabled) {
                                         $value['optionValues'][$key]['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', !$scopePrice, $_value->getOptionTypeId());
                                     }
                                     $value['optionValues'][$key]['scopePriceDisabled'] = !$scopePrice ? 'disabled' : null;
                                     //}
                                 }
                             }
                         }
                         $value['optionValues'] = array_values($value['optionValues']);
                     }
                 } else {
                     if (isset($storeOptionsArr[$optionId]['price'])) {
                         $option->setPrice(floatval($storeOptionsArr[$optionId]['price']));
                     }
                     if (isset($storeOptionsArr[$optionId]['price_type'])) {
                         $option->setPriceType($storeOptionsArr[$optionId]['price_type']);
                     }
                     $helper->applyLinkedBySkuDataToOption($option, $option->getSku(), $store, 0);
                     $helper->calculateOptionSpecialPrice($option, null, false);
                     $priceDisabled = $option->getIsSkuPrice();
                     list($skuClass, $viewProductBySkuHtml) = $this->getViewSkuData($option->getSku());
                     $value['price'] = $this->getPriceValue($option->getPrice(), $option->getPriceType());
                     $value['price_type'] = $option->getPriceType();
                     $value['price_disabled'] = $priceDisabled;
                     $value['sku'] = $this->htmlEscape($option->getSku());
                     $value['sku_class'] = $skuClass;
                     $value['view_product_by_sku_html'] = $viewProductBySkuHtml;
                     $value['max_characters'] = $option->getMaxCharacters();
                     $value['default_text'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['default_text']) ? $storeOptionsArr[$optionId]['default_text'] : $option->getDefaultText());
                     $value['file_extension'] = $option->getFileExtension();
                     $value['image_size_x'] = $option->getImageSizeX();
                     $value['image_size_y'] = $option->getImageSizeY();
                     $value['image_button_label'] = $helper->__('Add Image');
                     $imgHtml = $helper->getImgHtml($helper->getImgData($option->getImagePath(), $option->getId()));
                     if ($imgHtml) {
                         $value['image'] = $imgHtml;
                         $value['image_button_label'] = $helper->__('Change Image');
                     }
                     if ($this->getStoreId() != '0') {
                         //&& $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE
                         if (!$priceDisabled) {
                             $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', !isset($storeOptionsArr[$optionId]['price']));
                         }
                         $value['scopePriceDisabled'] = !isset($storeOptionsArr[$optionId]['price']) ? 'disabled' : null;
                         $value['checkboxScopeDefaultText'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'default_text', !isset($storeOptionsArr[$optionId]['default_text']));
                         $value['scopeDefaultTextDisabled'] = !isset($storeOptionsArr[$optionId]['default_text']) ? 'disabled' : null;
                     }
                 }
                 $values[] = new Varien_Object($value);
             }
         }
         $this->_values = $values;
     }
     return $this->_values ? $this->_values : array();
 }
Example #15
0
 /**
  * Add filter with a callback
  *
  * @param string $field    field to filter
  * @param string $value    value
  * @param string $type     and|or
  * @param string $callback callback method
  *
  * @return Smile_MageCache_Model_Action_Collection
  */
 public function addCallbackFilter($field, $value, $type = 'and', $callback = 'filterCallbackEqual')
 {
     $filter = new Varien_Object();
     $filter->setField($field);
     $filter->setValue($value);
     $filter->setType(strtolower($type));
     $filter->setCallback($callback);
     $this->_filters[] = $filter;
     $this->_isFiltersRendered = false;
     return $this;
 }
 /**
  * 
  */
 public function getParts()
 {
     $__AH = Mage::helper('activitystream/adminhtml');
     $__recordTemplate = $__AH->getActivityRecordTemplate($this->getActivity()->getType());
     $__variablesList = $__AH->getActivityTypePossibleVariables($this->getActivity()->getType());
     $__parts = array();
     while (strlen($__recordTemplate) > 0) {
         $__closestVariablePos = null;
         $__closestVariableName = null;
         foreach ($__variablesList as $__variableName) {
             $__variablePos = strpos($__recordTemplate, '{' . $__variableName . '}');
             if ($__variablePos === false) {
                 continue;
             }
             if (is_null($__closestVariablePos) or $__closestVariablePos > $__variablePos) {
                 $__closestVariablePos = $__variablePos;
                 $__closestVariableName = $__variableName;
             }
         }
         if (!is_null($__closestVariablePos)) {
             if ($__closestVariablePos > 0) {
                 $__part = new Varien_Object();
                 $__part->setType(self::PART_TYPE_PLAINTEXT)->setContent(substr($__recordTemplate, 0, $__closestVariablePos));
                 array_push($__parts, $__part);
                 $__recordTemplate = substr($__recordTemplate, $__closestVariablePos);
             }
             $__part = new Varien_Object();
             $__variableName = $__closestVariableName;
             $__value = $this->getActivity()->getData($__AH->getActivityRecordVariableDataKey($__variableName));
             if (!$__value) {
                 $__value = $this->getActivity()->getData(self::DATAKEY_PREFIX_DEFAULT . $__AH->getActivityRecordVariableDataKey($__variableName));
                 if (!$__value) {
                     $__value = $__AH->getActivityRecordVariableDelaultValue($this->getActivity()->getType(), $__variableName);
                     $__part->setIsValueDefault(true);
                 }
             }
             $__part->setType(self::PART_TYPE_VARIABLE)->setName($__variableName)->setValue($__value);
             if (!$__part->getIsValueDefault()) {
                 if ($__variableName == 'Product_title') {
                     $__product = Mage::getModel('catalog/product')->load($this->getActivity()->getProductId());
                     $__product->setStoreId($this->getActivity()->getStoreId());
                     $__part->setUrl(Mage::helper('catalog/product')->getProductUrl($__product));
                     unset($__product);
                 }
                 if ($__variableName == 'Category_title') {
                     $__category = Mage::getModel('catalog/category')->load($this->getActivity()->getCategoryId());
                     $__category->setStoreId($this->getActivity()->getStoreId());
                     $__part->setUrl($this->__getCategoryUrl($__category));
                     unset($__category);
                 }
             }
             array_push($__parts, $__part);
             $__recordTemplate = substr($__recordTemplate, strlen($__closestVariableName) + 2);
         } else {
             $__part = new Varien_Object();
             $__part->setType(self::PART_TYPE_PLAINTEXT)->setContent($__recordTemplate);
             array_push($__parts, $__part);
             $__recordTemplate = '';
         }
     }
     return $__parts;
 }