PHP Varien_Object Code Examples

This page contains top rated real world PHP examples of Varien_Object extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: Increment.php Project: Airmal/Magento-Em
0
 /**
  * Set new increment id
  *
  * @param Varien_Object $object
  * @return Mage_Eav_Model_Entity_Attribute_Backend_Increment
  */
 public function beforeSave($object)
 {
     if (!$object->getId()) {
         $this->getAttribute()->getEntity()->setNewIncrementId($object);
     }
     return $this;
 }
Example #2
Show file File: Form.php Project: jsiefer/emarketing
0
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
     $form->setHtmlIdPrefix("template");
     $form->setFieldNameSuffix("template");
     /* @var $template Mzax_Emarketing_Model_Template */
     $template = Mage::registry('current_template');
     if ($template->getId()) {
         $form->addField('template_id', 'hidden', array('name' => 'template_id', 'value' => $template->getId()));
     }
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => $this->__('Template Option'), 'class' => 'fieldset-wide'))->addType('editor', Mage::getConfig()->getModelClassName('mzax_emarketing/form_element_templateEditor'))->addType('credits', Mage::getConfig()->getModelClassName('mzax_emarketing/form_element_credits'));
     $fieldset->addField('credits', 'credits', array('name' => 'credits', 'required' => true));
     $fieldset->addField('name', 'text', array('name' => 'name', 'required' => true, 'label' => $this->__('Template Name'), 'title' => $this->__('Template Name')));
     $fieldset->addField('description', 'textarea', array('name' => 'description', 'required' => true, 'label' => $this->__('Description'), 'title' => $this->__('Description'), 'style' => 'height:4em;', 'note' => "For internal use only"));
     $snippets = new Mzax_Emarketing_Model_Medium_Email_Snippets();
     Mage::getSingleton('mzax_emarketing/medium_email')->prepareSnippets($snippets);
     $editorConfig = new Varien_Object();
     $editorConfig->setFilesBrowserWindowUrl($this->getUrl('adminhtml/cms_wysiwyg_images/index'));
     $editorConfig->setWidgetWindowUrl($this->getUrl('adminhtml/widget/index'));
     $editorConfig->setSnippets($snippets);
     $editor = $fieldset->addField('body', 'editor', array('name' => 'body', 'required' => true, 'label' => $this->__('Template HTML'), 'title' => $this->__('Template HTML'), 'logo' => $this->getSkinUrl('images/logo.gif'), 'fullscreen_title' => $this->__('Template %s', $template->getName()), 'style' => 'height:50em;', 'value' => '', 'config' => $editorConfig));
     // Setting custom renderer for content field to remove label column
     $renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element')->setTemplate('cms/page/edit/form/renderer/content.phtml');
     $editor->setRenderer($renderer);
     $form->addValues($template->getData());
     $this->setForm($form);
     $form->setUseContainer(true);
     return parent::_prepareForm();
 }
Example #3
Show file File: Found.php Project: nemphys/magento2
0
 /**
  * validate
  *
  * @param Varien_Object $object Quote
  * @return boolean
  */
 public function validate(Varien_Object $object)
 {
     $all = $this->getAggregator() === 'all';
     $true = (bool) $this->getValue();
     $found = false;
     foreach ($object->getAllItems() as $item) {
         $found = $all;
         foreach ($this->getConditions() as $cond) {
             $validated = $cond->validate($item);
             if ($all && !$validated || !$all && $validated) {
                 $found = $validated;
                 break;
             }
         }
         if ($found && $true || !$true && $found) {
             break;
         }
     }
     // found an item and we're looking for existing one
     if ($found && $true) {
         return true;
     } elseif (!$found && !$true) {
         return true;
     }
     return false;
 }
Example #4
Show file File: Result.php Project: ngagestudios/Vehicle-Fits-Magento
0
 /**
  * Get active status of category
  *
  * @param   Varien_Object $category
  * @return  bool
  */
 function isCategoryActive($category)
 {
     if ($this->getCurrentCategory()) {
         return in_array($category->getId(), $this->getCurrentCategory()->getPathIds());
     }
     return false;
 }
Example #5
Show file File: Config.php Project: evinw/project_bloom_magento
0
 /**
  * Validate attribute data
  *
  * @param Varien_Object $object
  * @return boolean
  */
 public function validate($object)
 {
     // all attribute's options
     $optionsAllowed = array('0', '1', '2');
     $value = $object->getData($this->getAttribute()->getAttributeCode());
     return in_array($value, $optionsAllowed) ? true : false;
 }
Example #6
Show file File: Purchases.php Project: xiaoguizhidao/blingjewelry-prod
0
 /**
  * Renders Purchases value
  *
  * @param   Varien_Object $row
  * @return  string
  */
 public function render(Varien_Object $row)
 {
     if (($value = $row->getData($this->getColumn()->getIndex())) > 0) {
         return $value;
     }
     return $this->__('Unlimited');
 }
Example #7
Show file File: Observer.php Project: booklein/bookle
0
 /**
  *
  */
 public function initControllerRouters($observer)
 {
     $request = $observer->getEvent()->getFront()->getRequest();
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('brand_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $route = trim(Mage::getStoreConfig('ves_brand/general_setting/route'));
     if ($identifier) {
         if (preg_match("#^" . $route . "(\\.html)?\$#", $identifier, $match)) {
             $request->setModuleName('venusbrand')->setControllerName('brand')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         }
         return true;
     }
     return false;
 }
Example #8
Show file File: Config.php Project: xiaoguizhidao/mydigibits
0
 /**
  * Prepare variable wysiwyg config
  *
  * @param Varien_Object $config
  * @return array
  */
 public function getWysiwygPluginSettings($config)
 {
     $configPlugins = $config->getData('plugins');
     $configPlugins[0]['options']['url'] = $this->getVariablesWysiwygActionUrl();
     $configPlugins[0]['options']['onclick']['subject'] = 'MagentovariablePlugin.loadChooser(\'' . $this->getVariablesWysiwygActionUrl() . '\', \'{{html_id}}\');';
     return $configPlugins;
 }
Example #9
Show file File: Outbound.php Project: ridhoq/mxpi-twitter
0
 /**
  * @param null|Varien_Object $dataObject
  * @return Xcom_Xfabric_Model_Message_Request
  */
 public function _prepareData(Varien_Object $dataObject = null)
 {
     $avroDataObject = Mage::getModel('xcom_chronicle/message_product', $dataObject->getProduct());
     $data = array('products' => array($avroDataObject->toArray()));
     $this->setMessageData($data);
     return parent::_prepareData($dataObject);
 }
Example #10
Show file
0
 public function render(Varien_Object $row)
 {
     if (!$row->getData($this->getColumn()->getIndex())) {
         return null;
     }
     return '<a title="' . Mage::helper('core')->__('Edit Store') . '" href="' . $this->getUrl('*/*/editGroup', array('group_id' => $row->getGroupId())) . '">' . $row->getData($this->getColumn()->getIndex()) . '</a>';
 }
Example #11
Show file File: Url.php Project: jronatay/ultimo-magento-jron
0
 /**
  * Get unique category request path
  *
  * @param Varien_Object $category
  * @param string $parentPath
  * @return string
  */
 public function getCategoryRequestPath($category, $parentPath)
 {
     $storeId = $category->getStoreId();
     $idPath = $this->generatePath('id', null, $category);
     $suffix = $this->getCategoryUrlSuffix($storeId);
     if (isset($this->_rewrites[$idPath])) {
         $this->_rewrite = $this->_rewrites[$idPath];
         $existingRequestPath = $this->_rewrites[$idPath]->getRequestPath();
     }
     if ($category->getUrlKey() == '') {
         $urlKey = $this->getCategoryModel()->formatUrlKey($category->getName());
     } else {
         $urlKey = $this->getCategoryModel()->formatUrlKey($category->getUrlKey());
     }
     $categoryUrlSuffix = $this->getCategoryUrlSuffix($category->getStoreId());
     if (null === $parentPath) {
         $parentPath = $this->getResource()->getCategoryParentPath($category);
     } elseif ($parentPath == '/') {
         $parentPath = '';
     }
     $parentPath = Mage::helper('catalog/category')->getCategoryUrlPath($parentPath, true, $category->getStoreId());
     // Only filter category URL paths when not in B2B store.
     if (Mage::helper("mey_b2b")->getStoreId() != $storeId) {
         $parentPath = $this->_filterCategoriesFromRequestPath($parentPath);
     }
     $requestPath = $parentPath . $urlKey . $categoryUrlSuffix;
     if (isset($existingRequestPath) && $existingRequestPath == $requestPath . $suffix) {
         return $existingRequestPath;
     }
     if ($this->_deleteOldTargetPath($requestPath, $idPath, $storeId)) {
         return $requestPath;
     }
     return $this->getUnusedPath($category->getStoreId(), $requestPath, $this->generatePath('id', null, $category));
 }
Example #12
Show file File: Action.php Project: pawlik/magerun-addons
0
 /**
  * Factory method to get proper action instance
  *
  * @param array $config
  * @throws \Exception
  */
 public function assign(array $config)
 {
     $action = $parameters = NULL;
     if (!isset($config[self::F_PARAMETERS]) && sizeof($config) >= 2) {
         $parameters = array_pop($config);
         if (!is_array($parameters)) {
             $parameters = (array) $parameters;
         }
     } elseif (isset($config[self::F_PARAMETERS])) {
         $parameters = $config[self::F_PARAMETERS];
     }
     $action = (string) array_shift($config);
     if (NULL === $action || NULL === $parameters) {
         throw new \Exception(sprintf('Invalid action entry - %s', var_export($config, TRUE)));
     }
     $raw = $action;
     list($scope, $action) = explode('/', $raw, 2);
     // drop all hard spaces
     $action = str_replace('_', '', $action);
     // unlike Mage::helper() this one returns FALSE when model is not found
     // change whole config to use new action name and remove this ugly hack
     // we can't have default namespace, but in config we have such entry
     $scope = $scope == 'default' ? $scope . 'scope' : $scope;
     $className = '\\Nexway\\SetupManager\\Util\\Processor\\Action\\' . ucfirst($scope) . '\\' . ucfirst($action);
     $base = new $className();
     if (FALSE === $base) {
         throw new \Exception(sprintf('Invalid action - %s/%s', $scope, $action));
     }
     $parametersObject = new \Varien_Object();
     $parametersObject->setData($parameters);
     return $base->setAction($action)->setScope($scope)->setParameters($parametersObject);
 }
Example #13
Show file File: Child.php Project: par-orillonsoft/magento_work
0
 /**
  * Method is invoked before save
  *
  * @param Varien_Object $object
  * @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
  */
 public function beforeSave($object)
 {
     if ($object->getCreditmemo()) {
         $object->setParentId($object->getCreditmemo()->getId());
     }
     return parent::beforeSave($object);
 }
Example #14
Show file File: Form.php Project: kanotest15/cbmagento
0
 /**
  * prepare tab form's information
  *
  * @return Magestore_RewardPoints_Block_Adminhtml_Spending_Edit_Tab_Form
  */
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     if (Mage::getSingleton('adminhtml/session')->getFormData()) {
         $data = Mage::getSingleton('adminhtml/session')->getFormData();
         Mage::getSingleton('adminhtml/session')->setFormData(null);
     } elseif (Mage::registry('rate_data')) {
         $data = Mage::registry('rate_data')->getData();
     }
     $fieldset = $form->addFieldset('rewardpoints_form', array('legend' => Mage::helper('rewardpoints')->__('Rate information')));
     $dataObj = new Varien_Object($data);
     $data = $dataObj->getData();
     $fieldset->addField('points', 'text', array('label' => Mage::helper('rewardpoints')->__('Spending Point(s)'), 'title' => Mage::helper('rewardpoints')->__('Spending Point(s)'), 'required' => true, 'name' => 'points'));
     $fieldset->addField('money', 'text', array('name' => 'money', 'label' => Mage::helper('rewardpoints')->__('Discount received'), 'title' => Mage::helper('rewardpoints')->__('Discount received'), 'required' => true, 'after_element_html' => '<strong>[' . Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE) . ']</strong>', 'note' => Mage::helper('rewardpoints')->__('the equivalent value of points')));
     //Hai.Tran 12/11/2013 fix gioi han spend points
     $fieldset->addField('max_price_spended_type', 'select', array('label' => Mage::helper('rewardpoints')->__('Limit spending points based on'), 'title' => Mage::helper('rewardpoints')->__('Limit spending points based on'), 'name' => 'max_price_spended_type', 'options' => array('none' => Mage::helper('rewardpoints')->__('None'), 'by_price' => Mage::helper('rewardpoints')->__('A fixed amount of Total Order Value'), 'by_percent' => Mage::helper('rewardpoints')->__('A percentage of Total Order Value')), 'onchange' => 'toggleMaxPriceSpend()', 'note' => Mage::helper('rewardpoints')->__('Select the type to limit spending points')));
     $fieldset->addField('max_price_spended_value', 'text', array('label' => Mage::helper('rewardpoints')->__('Limit value allowed to spend points at'), 'title' => Mage::helper('rewardpoints')->__('Limit value allowed to spend points at'), 'name' => 'max_price_spended_value', 'note' => Mage::helper('rewardpoints')->__('If empty or zero, there is no limitation.')));
     //End Hai.Tran 12/11/2013
     if (!Mage::app()->isSingleStoreMode()) {
         $fieldset->addField('website_ids', 'multiselect', array('name' => 'website_ids[]', 'label' => Mage::helper('rewardpoints')->__('Websites'), 'title' => Mage::helper('rewardpoints')->__('Websites'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_config_source_website')->toOptionArray()));
     } else {
         $fieldset->addField('website_ids', 'hidden', array('name' => 'website_ids[]', 'value' => Mage::app()->getStore(true)->getWebsiteId()));
         $data['website_ids'] = Mage::app()->getStore(true)->getWebsiteId();
     }
     $fieldset->addField('customer_group_ids', 'multiselect', array('label' => Mage::helper('rewardpoints')->__('Customer groups'), 'title' => Mage::helper('rewardpoints')->__('Customer groups'), 'name' => 'customer_group_ids', 'required' => true, 'values' => Mage::getResourceModel('customer/group_collection')->addFieldToFilter('customer_group_id', array('gt' => 0))->load()->toOptionArray()));
     $fieldset->addField('sort_order', 'text', array('label' => Mage::helper('rewardpoints')->__('Priority'), 'label' => Mage::helper('rewardpoints')->__('Priority'), 'required' => false, 'name' => 'sort_order', 'note' => Mage::helper('rewardpoints')->__('Higher priority Rate will be applied first')));
     $form->setValues($data);
     $this->setForm($form);
     Mage::dispatchEvent('rewardpoints_adminhtml_spending_rate_form', array('tab_form' => $this, 'form' => $form, 'data' => $dataObj));
     return parent::_prepareForm();
 }
Example #15
Show file File: Default.php Project: xiaoguizhidao/blingjewelry-prod
0
 public function render(Varien_Object $value)
 {
     $code = $value->getData('item_value/code');
     $item = $value->getItem();
     $result = '';
     $itemRenderer = $this->getItemRendererBlock();
     if ($code !== '') {
         if ($code == 'name') {
             $result = $this->htmlEscape($item->getName());
         } elseif ($code == 'sku') {
             $result = implode('<br />', Mage::helper('catalog')->splitSku($this->htmlEscape($item->getSku())));
         } elseif ($code == 'quantity') {
             if ($value->hasOrder()) {
                 $result = $itemRenderer->getColumnHtml($item, 'qty');
             } else {
                 $result = $item->getQty() * 1;
             }
         } elseif ($code == 'original_price' || $code == 'tax_amount' || $code == 'discount_amount') {
             $result = $itemRenderer->displayPriceAttribute($code);
         } elseif ($code == 'tax_percent') {
             $result = $itemRenderer->displayTaxPercent($item);
         } elseif ($code == 'row_total') {
             if (Mage::helper('customgrid')->isMageVersionLesserThan(1, 6)) {
                 $result = $itemRenderer->displayPrices($item->getBaseRowTotal() - $item->getBaseDiscountAmount() + $item->getBaseTaxAmount() + $item->getBaseWeeeTaxAppliedRowAmount(), $item->getRowTotal() - $item->getDiscountAmount() + $item->getTaxAmount() + $item->getWeeeTaxAppliedRowAmount());
             } else {
                 $result = $itemRenderer->displayPrices($item->getBaseRowTotal() + $item->getBaseTaxAmount() + $item->getBaseHiddenTaxAmount() + $item->getBaseWeeeTaxAppliedRowAmount() - $item->getBaseDiscountAmount(), $item->getRowTotal() + $item->getTaxAmount() + $item->getHiddenTaxAmount() + $item->getWeeeTaxAppliedRowAmount() - $item->getDiscountAmount());
             }
         } else {
             $result = $item->getDataUsingMethod($code);
         }
     }
     return $result;
 }
Example #16
Show file File: Collection.php Project: hunnybohara/magento-chinese-localization
0
 public function load($printQuery = false, $logQuery = false)
 {
     $this->_select = $this->_read->select();
     $entityTable = $this->getEntity()->getEntityTable();
     $paidTable = $this->getAttribute('grand_total')->getBackend()->getTable();
     $idField = $this->getEntity()->getIdFieldName();
     $this->getSelect()->from(array('sales' => $entityTable), array('store_id', 'lifetime' => 'sum(sales.base_grand_total)', 'avgsale' => 'avg(sales.base_grand_total)', 'num_orders' => 'count(sales.base_grand_total)'))->where('sales.entity_type_id=?', $this->getEntity()->getTypeId())->group('sales.store_id');
     if ($this->_customer instanceof Mage_Customer_Model_Customer) {
         $this->getSelect()->where('sales.customer_id=?', $this->_customer->getId());
     }
     $this->printLogQuery($printQuery, $logQuery);
     try {
         $values = $this->_read->fetchAll($this->getSelect()->__toString());
     } catch (Exception $e) {
         $this->printLogQuery(true, true, $this->getSelect()->__toString());
         throw $e;
     }
     $stores = Mage::getResourceModel('core/store_collection')->setWithoutDefaultFilter()->load()->toOptionHash();
     if (!empty($values)) {
         foreach ($values as $v) {
             $obj = new Varien_Object($v);
             $storeName = isset($stores[$obj->getStoreId()]) ? $stores[$obj->getStoreId()] : null;
             $this->_items[$v['store_id']] = $obj;
             $this->_items[$v['store_id']]->setStoreName($storeName);
             $this->_items[$v['store_id']]->setAvgNormalized($obj->getAvgsale() * $obj->getNumOrders());
             foreach ($this->_totals as $key => $value) {
                 $this->_totals[$key] += $obj->getData($key);
             }
         }
         if ($this->_totals['num_orders']) {
             $this->_totals['avgsale'] = $this->_totals['lifetime'] / $this->_totals['num_orders'];
         }
     }
     return $this;
 }
Example #17
Show file File: Totals.php Project: test3metizsoft/test
0
 /**
  * Format total value based on order currency
  *
  * @param   Varien_Object $total
  * @return  string
  */
 public function formatValue($total)
 {
     if (!$total->getIsFormated()) {
         return $this->helper('adminhtml/sales')->displayPrices($this->getOrder(), $total->getBaseValue(), $total->getValue());
     }
     return $total->getValue();
 }
Example #18
Show file File: Pro.php Project: QiuLihua83/magento-enterprise-1.13.1.0
0
 /**
  * Get payflow transaction id from parent transaction
  *
  * @param Varien_Object $payment
  * @return string
  */
 protected function _getParentTransactionId(Varien_Object $payment)
 {
     if ($payment->getParentTransactionId()) {
         return $payment->getTransaction($payment->getParentTransactionId())->getAdditionalInformation(Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID);
     }
     return $payment->getParentTransactionId();
 }
Example #19
Show file File: View.php Project: ausger/myporto
0
 public function _getJsonConfig()
 {
     $config = array();
     if (!$this->hasOptions()) {
         return Mage::helper('core')->jsonEncode($config);
     }
     $_request = Mage::getSingleton('tax/calculation')->getRateRequest(false, false, false);
     /* @var $product Mage_Catalog_Model_Product */
     $product = $this->getProduct();
     $_request->setProductClassId($product->getTaxClassId());
     $defaultTax = Mage::getSingleton('tax/calculation')->getRate($_request);
     $_request = Mage::getSingleton('tax/calculation')->getRateRequest();
     $_request->setProductClassId($product->getTaxClassId());
     $currentTax = Mage::getSingleton('tax/calculation')->getRate($_request);
     $_regularPrice = $product->getPrice();
     $_finalPrice = $product->getFinalPrice();
     $_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true);
     $_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice);
     $_tierPrices = array();
     $_tierPricesInclTax = array();
     foreach ($product->getTierPrice() as $tierPrice) {
         $_tierPrices[] = Mage::helper('core')->currency($tierPrice['website_price'], false, false);
         $_tierPricesInclTax[] = Mage::helper('core')->currency(Mage::helper('tax')->getPrice($product, (int) $tierPrice['website_price'], true), false, false);
     }
     $config = array('productId' => $product->getId(), 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false', 'showIncludeTax' => Mage::helper('tax')->displayPriceIncludingTax(), 'showBothPrices' => Mage::helper('tax')->displayBothPrices(), 'productPrice' => Mage::helper('core')->currency($_finalPrice, false, false), 'productOldPrice' => Mage::helper('core')->currency($_regularPrice, false, false), 'priceInclTax' => Mage::helper('core')->currency($_priceInclTax, false, false), 'priceExclTax' => Mage::helper('core')->currency($_priceExclTax, false, false), 'skipCalculate' => $_priceExclTax != $_priceInclTax ? 0 : 1, 'defaultTax' => $defaultTax, 'currentTax' => $currentTax, 'idSuffix' => '_cloneover', 'oldPlusDisposition' => 0, 'plusDisposition' => 0, 'plusDispositionTax' => 0, 'oldMinusDisposition' => 0, 'minusDisposition' => 0, 'tierPrices' => $_tierPrices, 'tierPricesInclTax' => $_tierPricesInclTax);
     $responseObject = new Varien_Object();
     Mage::dispatchEvent('catalog_product_view_config', array('response_object' => $responseObject));
     if (is_array($responseObject->getAdditionalOptions())) {
         foreach ($responseObject->getAdditionalOptions() as $option => $value) {
             $config[$option] = $value;
         }
     }
     return Mage::helper('core')->jsonEncode($config);
 }
Example #20
Show file File: ProductController.php Project: sergeykalenyuk/Tadic_AVP
0
 /**
  * This is a straigh copy/paste of
  *
  *   Mage_Catalog_ProductController::viewAction()
  *
  * Only change is that I replaced the $viewHelper so that we could
  * hook into prepareAndRender()
  */
 public function previewAction()
 {
     // Get initial data from request
     $categoryId = (int) $this->getRequest()->getParam('category', false);
     $productId = (int) $this->getRequest()->getParam('id');
     $specifyOptions = $this->getRequest()->getParam('options');
     // Prepare helper and params
     $viewHelper = Mage::helper('tadic_avp/catalog_product_view');
     $params = new Varien_Object();
     $params->setCategoryId($categoryId);
     $params->setSpecifyOptions($specifyOptions);
     // Render page
     try {
         $viewHelper->prepareAndRender($productId, $this, $params);
     } catch (Exception $e) {
         if ($e->getCode() == $viewHelper->ERR_NO_PRODUCT_LOADED) {
             if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) {
                 $this->_redirect('');
             } elseif (!$this->getResponse()->isRedirect()) {
                 $this->_forward('noRoute');
             }
         } else {
             Mage::logException($e);
             $this->_forward('noRoute');
         }
     }
 }
Example #21
Show file File: Date.php Project: nitronaj/magentofa
0
 /**
  * Renders grid column
  *
  * @param Varien_Object $row
  * @return string
  */
 public function render(Varien_Object $row)
 {
     if ($data = $row->getData($this->getColumn()->getIndex())) {
         if (Mage::app()->getLocale()->getLocale() == 'fa_IR') {
             require_once Mage::getBaseDir('lib') . '/pdate/pdate.php';
             $time = strtotime($data);
             $data = pdate('Y-m-d H:i:s', $time);
         }
         switch ($this->getColumn()->getPeriodType()) {
             case 'month':
                 $dateFormat = 'yyyy-MM';
                 break;
             case 'year':
                 $dateFormat = 'yyyy';
                 break;
             default:
                 $dateFormat = Varien_Date::DATE_INTERNAL_FORMAT;
                 break;
         }
         $format = $this->_getFormat();
         try {
             $data = $this->getColumn()->getGmtoffset() ? Mage::app()->getLocale()->date($data, $dateFormat)->toString($format) : Mage::getSingleton('core/locale')->date($data, Zend_Date::ISO_8601, null, false)->toString($format);
         } catch (Exception $e) {
             $data = $this->getColumn()->getTimezone() ? Mage::app()->getLocale()->date($data, $dateFormat)->toString($format) : Mage::getSingleton('core/locale')->date($data, $dateFormat, null, false)->toString($format);
         }
         return $data;
     }
     return $this->getColumn()->getDefault();
 }
Example #22
Show file File: Observer.php Project: booklein/bookle
0
 /**
  *
  */
 public function initControllerRouters($observer)
 {
     Mage::getSingleton('core/session', array('name' => 'adminhtml'));
     if (!is_null(Mage::registry("_singleton/admin/session"))) {
         if (Mage::getSingleton('admin/session')->isLoggedIn()) {
             /*Is admin*/
             //do stuff
             return;
         }
     }
     $request = $observer->getEvent()->getFront()->getRequest();
     if (!Mage::app()->isInstalled()) {
         /*
         Mage::app()->getFrontController()->getResponse()
             ->setRedirect(Mage::getUrl('install'))
             ->sendResponse();
         */
         return;
     }
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('blog_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     $identifier = trim($identifier, "/");
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $route = trim(Mage::getStoreConfig('ves_blog/general_setting/route'));
     if ($identifier) {
         if (preg_match("#^" . $route . "(\\.html)?\$#", $identifier, $match)) {
             $request->setModuleName('venusblog')->setControllerName('index')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (str_replace('/rss', '', str_replace($route, '', $identifier)) == '') {
             $request->setModuleName('venusblog')->setControllerName('rss')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (preg_match("#" . $route . "/tag/(\\w+)\\.?#", $identifier, $match)) {
             if (count($match) <= 1) {
                 return false;
             }
             $request->setModuleName('venusblog')->setControllerName('list')->setActionName('show')->setParam("tag", $match[1]);
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (preg_match("#" . $route . "/archive/(\\w+)\\.?#", $identifier, $match)) {
             if (count($match) <= 1) {
                 return false;
             }
             $request->setModuleName('venusblog')->setControllerName('list')->setActionName('show')->setParam("archive", $match[1]);
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         }
     }
     return false;
 }
Example #23
Show file File: Form.php Project: cewolf2002/magento
0
 /**
  * Prepare form
  *
  * @return Mage_Adminhtml_Block_Widget_Form
  */
 protected function _prepareForm()
 {
     $model = Mage::registry('current_template');
     if (!$model) {
         $model = new Varien_Object();
     }
     $action = $this->getUrl('*/*/saveTemplate');
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $action, 'method' => 'post', 'enctype' => 'multipart/form-data'));
     $form->setHtmlIdPrefix('template_');
     $fieldset = $form->addFieldset('edit_template', array('legend' => $this->__('Template')));
     $this->_addElementTypes($fieldset);
     if ($model->getId()) {
         $fieldset->addField('id', 'hidden', array('name' => 'id'));
         $fieldset->addField('template_id', 'hidden', array('name' => 'template_id'));
     }
     $fieldset->addField('application_id', 'select', array('name' => 'application_id', 'label' => $this->__('Application'), 'title' => $this->__('Application'), 'disabled' => $model->getId() || !$this->_fieldsEnabled ? true : false, 'values' => Mage::helper('xmlconnect')->getApplicationOptions(), 'note' => $this->__('Creating a Template is allowed only for applications which have device type iPhone.'), 'required' => true));
     $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Template Name'), 'title' => $this->__('Template Name'), 'required' => true, 'disabled' => $model->getId() || !$this->_fieldsEnabled ? true : false, 'note' => $this->__('Maximum length is 255'), 'maxlength' => 255));
     $fieldset->addField('push_title', 'text', array('name' => 'push_title', 'label' => $this->__('Push Title'), 'title' => $this->__('Push Title'), 'required' => true, 'disabled' => !$this->_fieldsEnabled ? true : false, 'note' => $this->__('Maximum length is 140'), 'maxlength' => 140));
     $this->_dependentFields['message_title'] = $fieldset->addField('message_title', 'text', array('name' => 'message_title', 'label' => $this->__('Message Title'), 'title' => $this->__('Message Title'), 'required' => true, 'disabled' => !$this->_fieldsEnabled ? true : false, 'note' => $this->__('Maximum length is 255'), 'maxlength' => 255));
     $widgetFilters = array('is_email_compatible' => 1);
     $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('widget_filters' => $widgetFilters));
     $this->_dependentFields['content'] = $fieldset->addField('content', 'editor', array('label' => $this->__('Template Content'), 'title' => $this->__('Template Content'), 'name' => 'content', 'style' => 'height:30em;', 'state' => 'html', 'required' => true, 'disabled' => !$this->_fieldsEnabled ? true : false, 'config' => $wysiwygConfig));
     $form->setValues($model->getData());
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Example #24
Show file File: Customeraddress.php Project: hueyl77/fourwindsgear
0
 /**
  * @param Varien_Object $row
  * @return mixed
  */
 public function render(Varien_Object $row)
 {
     $data = $row->getData($this->getColumn()->getIndex());
     $customer = Mage::getModel('customer/customer')->load($data);
     $address = Mage::getModel('customer/address')->load($customer->getDefaultShipping());
     return $address->format('html');
 }
Example #25
Show file File: Store.php Project: evinw/project_bloom_magento
0
 /**
  * Prepare data before save
  *
  * @param Varien_Object $object
  * @return Mage_Eav_Model_Entity_Attribute_Backend_Store
  */
 protected function _beforeSave($object)
 {
     if (!$object->getData($this->getAttribute()->getAttributeCode())) {
         $object->setData($this->getAttribute()->getAttributeCode(), Mage::app()->getStore()->getId());
     }
     return $this;
 }
Example #26
Show file File: Profile.php Project: QiuLihua83/magento-enterprise-1.13.1.0
0
 /**
  * Return recurring profile child Orders Ids
  *
  *
  * @param Varien_Object $object
  * @return array
  */
 public function getChildOrderIds($object)
 {
     $adapter = $this->_getReadAdapter();
     $bind = array(':profile_id' => $object->getId());
     $select = $adapter->select()->from(array('main_table' => $this->getTable('sales/recurring_profile_order')), array('order_id'))->where('profile_id=:profile_id');
     return $adapter->fetchCol($select, $bind);
 }
Example #27
Show file File: Inputtype.php Project: cewolf2002/magento
0
 /**
  * Get product input types as option array
  *
  * @return array
  */
 public function toOptionArray()
 {
     $inputTypes = array(array('value' => 'price', 'label' => Mage::helper('catalog')->__('Price')), array('value' => 'media_image', 'label' => Mage::helper('catalog')->__('Media Image')));
     $response = new Varien_Object();
     $response->setTypes(array());
     Mage::dispatchEvent('adminhtml_product_attribute_types', array('response' => $response));
     $_disabledTypes = array();
     $_hiddenFields = array();
     foreach ($response->getTypes() as $type) {
         $inputTypes[] = $type;
         if (isset($type['hide_fields'])) {
             $_hiddenFields[$type['value']] = $type['hide_fields'];
         }
         if (isset($type['disabled_types'])) {
             $_disabledTypes[$type['value']] = $type['disabled_types'];
         }
     }
     if (Mage::registry('attribute_type_hidden_fields') === null) {
         Mage::register('attribute_type_hidden_fields', $_hiddenFields);
     }
     if (Mage::registry('attribute_type_disabled_types') === null) {
         Mage::register('attribute_type_disabled_types', $_disabledTypes);
     }
     return array_merge(parent::toOptionArray(), $inputTypes);
 }
Example #28
Show file File: Program.php Project: billadams/forever-frame
0
 public function getStoreAttributes()
 {
     $storeAttribute = new Varien_Object(array('store_attribute' => array('name', 'affiliate_type', 'status', 'description', 'commission_type', 'commission', 'sec_commission', 'sec_commission_type', 'secondary_commission', 'discount_type', 'discount', 'sec_discount', 'sec_discount_type', 'secondary_discount', 'customer_group_ids', 'show_in_welcome', 'use_tier_config', 'max_level', 'tier_commission', 'use_sec_tier', 'sec_tier_commission')));
     /** Thanhpv - add even $this->_eventPrefix . '_get_store_attributes' (2012-10-11) */
     Mage::dispatchEvent($this->_eventPrefix . '_get_store_attributes', array($this->_eventObject => $this, 'attributes' => $storeAttribute));
     return $storeAttribute->getStoreAttribute();
 }
Example #29
Show file File: Abstract.php Project: shebin512/Magento_Zoff
0
 protected function _initCounter()
 {
     $counter = new Varien_Object();
     $counter->setLabel($this->_counterLabel);
     $counter->setCount(0);
     $this->_counter = $counter;
 }
Example #30
Show file File: Extended.php Project: xiaoguizhidao/ortodon
0
 /**
  * Modifies filter items and filter model itself as specified by extensions subscribed to 
  * morphes_filters_process_items event.
  * @param Mage_Catalog_Model_Layer_Filter_Abstract $filter
  * @param array $items
  */
 public function processFilterItems($filter, $items)
 {
     $wrappedItems = new Varien_Object();
     $wrappedItems->setItems($items);
     Mage::dispatchEvent('morphes_filters_process_items', array('filter' => $filter, 'items' => $wrappedItems));
     return $wrappedItems->getItems();
 }
Frequently Used Methods