public function getRatingSummary()
 {
     if (!$this->getRatingSummaryCache()) {
         $this->setRatingSummaryCache(Mage::getModel('rating/rating')->getReviewSummary($this->getReviewId()));
     }
     return $this->getRatingSummaryCache();
 }
Пример #2
1
 public function PostAction()
 {
     $evidencija_model = Mage::getModel('evidencija/evidencija');
     $devices_model = Mage::getModel('evidencija/devices');
     $post_name = $this->getRequest()->getPost('name');
     $post_sn = $this->getRequest()->getPost('sn');
     $post_supplier = $this->getRequest()->getPost('supplier');
     $post_comment = $this->getRequest()->getPost('comment');
     $post_warranty = $this->getRequest()->getPost('warranty');
     $helper = Mage::helper('evidencija');
     if (empty($post_sn[0])) {
         $this->redirectError('Morate uneti serijski broj !!!');
     } else {
         // prepare data for customer table
         $evidencija_data = array('name' => $post_name, 'supplier' => $post_supplier, 'comment' => $post_comment, 'warranty' => $post_warranty);
         $evidencija_model->setData($evidencija_data)->save();
         $evidencija_id = $evidencija_model->getEntityId();
         foreach ($post_sn as $key => $post) {
             if (empty($post)) {
                 continue;
             }
             // prepare data for device table
             $post = rtrim($post, "\r");
             $post = rtrim($post, "\n");
             $device_data = array('device_id' => $evidencija_id, 'serial' => $post);
             $devices_model->setData($device_data)->save();
         }
         if ($devices_model->getEntityId()) {
             Mage::getSingleton('core/session')->addSuccess($this->__('Nov uredjaj je uspešno dodat u bazu'));
         } else {
             Mage::getSingleton('core/session')->addError($this->__('Došlo je do greške, obavesti Dodu !'));
         }
         $this->_redirectReferer();
     }
 }
Пример #3
0
 protected function setUp()
 {
     $this->_product = Mage::getModel('Mage_Catalog_Model_Product');
     $this->_product->load(1);
     $this->_block = Mage::app()->getLayout()->createBlock('Mage_Catalog_Block_Product_View_Type_Configurable');
     $this->_block->setProduct($this->_product);
 }
Пример #4
0
 /**
  * Initialize template and cache settings
  *
  */
 protected function _construct()
 {
     parent::_construct();
     $this->setTemplate('inventoryplus/menu.phtml');
     $this->_url = Mage::getModel('adminhtml/url');
     $this->setCacheTags(array(self::CACHE_TAGS));
 }
Пример #5
0
 protected function _getOptionsCollection()
 {
     if (!$this->_collection) {
         $this->_collection = Mage::getModel('emjainteractive_shippingoption/option')->getCollection()->applySortOrder()->load();
     }
     return $this->_collection;
 }
 /**
  * Return Purchased link for order item
  *
  * @return Mage_Downloadable_Model_Link_Purchased
  */
 public function getLinks()
 {
     $this->_purchasedLinks = Mage::getModel('downloadable/link_purchased')->load($this->getOrder()->getId(), 'order_id');
     $purchasedItems = Mage::getModel('downloadable/link_purchased_item')->getCollection()->addFieldToFilter('order_item_id', $this->getItem()->getOrderItem()->getId());
     $this->_purchasedLinks->setPurchasedItems($purchasedItems);
     return $this->_purchasedLinks;
 }
Пример #7
0
 public function getCollection()
 {
     if (is_null($this->_collection)) {
         $this->setCollection(Mage::getModel('reports/grouped_collection'));
     }
     return $this->_collection;
 }
Пример #8
0
 protected function _prepareForm()
 {
     /*
      * Checking if user have permissions to save information
      */
     if ($this->_isAllowedAction('save')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     $form = new Varien_Data_Form();
     $form->setHtmlIdPrefix('page_');
     $model = Mage::registry('cms_page');
     $layoutFieldset = $form->addFieldset('layout_fieldset', array('legend' => Mage::helper('cms')->__('Page Layout'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled));
     $layoutFieldset->addField('root_template', 'select', array('name' => 'root_template', 'label' => Mage::helper('cms')->__('Layout'), 'required' => true, 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(), 'disabled' => $isElementDisabled));
     if (!$model->getId()) {
         $model->setRootTemplate(Mage::getSingleton('page/source_layout')->getDefaultValue());
     }
     $layoutFieldset->addField('layout_update_xml', 'textarea', array('name' => 'layout_update_xml', 'label' => Mage::helper('cms')->__('Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled));
     $designFieldset = $form->addFieldset('design_fieldset', array('legend' => Mage::helper('cms')->__('Custom Design'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled));
     $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
     $designFieldset->addField('custom_theme_from', 'date', array('name' => 'custom_theme_from', 'label' => Mage::helper('cms')->__('Custom Design From'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso, 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_theme_to', 'date', array('name' => 'custom_theme_to', 'label' => Mage::helper('cms')->__('Custom Design To'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso, 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_theme', 'select', array('name' => 'custom_theme', 'label' => Mage::helper('cms')->__('Custom Theme'), 'values' => Mage::getModel('core/design_source_design')->getAllOptions(), 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_root_template', 'select', array('name' => 'custom_root_template', 'label' => Mage::helper('cms')->__('Custom Layout'), 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(true), 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_layout_update_xml', 'textarea', array('name' => 'custom_layout_update_xml', 'label' => Mage::helper('cms')->__('Custom Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled));
     Mage::dispatchEvent('adminhtml_cms_page_edit_tab_design_prepare_form', array('form' => $form));
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #9
0
 protected function _prepareCollection()
 {
     $model = Mage::getModel('review/review');
     $collection = $model->getProductCollection();
     if ($this->getProductId() || $this->getRequest()->getParam('productId', false)) {
         $productId = $this->getProductId();
         if (!$productId) {
             $productId = $this->getRequest()->getParam('productId');
         }
         $this->setProductId($productId);
         $collection->addEntityFilter($this->getProductId());
     }
     if ($this->getCustomerId() || $this->getRequest()->getParam('customerId', false)) {
         $customerId = $this->getCustomerId();
         if (!$customerId) {
             $customerId = $this->getRequest()->getParam('customerId');
         }
         $this->setCustomerId($customerId);
         $collection->addCustomerFilter($this->getCustomerId());
     }
     if (Mage::registry('usePendingFilter') === true) {
         $collection->addStatusFilter($model->getPendingStatus());
     }
     $collection->addStoreData();
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Пример #10
0
 public function __construct()
 {
     parent::__construct();
     $this->setTemplate('sales/order/details.phtml');
     $this->setOrder(Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id')));
     Mage::registry('action')->getLayout()->getBlock('root')->setHeaderTitle(Mage::helper('sales')->__('Order Details'));
 }
Пример #11
0
 public function __construct()
 {
     parent::__construct();
     // Initialization block
     //------------------------------
     $this->setId('ebayFeedback');
     $this->_blockGroup = 'M2ePro';
     $this->_controller = 'adminhtml_ebay_feedback';
     //------------------------------
     // Set header text
     //------------------------------
     $accountTitle = '';
     $accountId = $this->getRequest()->getParam('account');
     if (!is_null($accountId)) {
         $accountTitle = Mage::getModel('M2ePro/Account')->load((int) $accountId)->getTitle();
     }
     $this->_headerText = Mage::helper('M2ePro')->__('Feedback for account "%s"', $accountTitle);
     //------------------------------
     // Set buttons actions
     //------------------------------
     $this->removeButton('back');
     $this->removeButton('reset');
     $this->removeButton('delete');
     $this->removeButton('add');
     $this->removeButton('save');
     $this->removeButton('edit');
     $this->_addButton('goto_orders', array('label' => Mage::helper('M2ePro')->__('Orders'), 'onclick' => 'setLocation(\'' . $this->getUrl('*/adminhtml_ebay_order/index') . '\')', 'class' => 'button_link'));
     $this->_addButton('goto_accounts', array('label' => Mage::helper('M2ePro')->__('Accounts'), 'onclick' => 'setLocation(\'' . $this->getUrl('*/adminhtml_ebay_account/index') . '\')', 'class' => 'button_link'));
     $this->_addButton('reset', array('label' => Mage::helper('M2ePro')->__('Refresh'), 'onclick' => 'EbayFeedbackHandlerObj.reset_click()', 'class' => 'reset'));
     //------------------------------
 }
Пример #12
0
 public function ajaxAction()
 {
     $idItem = Mage::app()->getRequest()->getParam('idItem');
     Mage::register('current_log', Mage::getModel('amaudit/log')->load($idItem));
     $block = $this->getLayout()->createBlock('amaudit/adminhtml_userlog_edit_tab_view_details');
     $this->getResponse()->setBody($block->toHtml());
 }
Пример #13
0
 /**
  * Prepare form before rendering HTML
  * Setting Form Fieldsets and fields
  *
  * @return Mage_Adminhtml_Block_Widget_Form
  */
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     $this->setForm($form);
     $data = Mage::helper('xmlconnect')->getApplication()->getFormData();
     $yesNoValues = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
     $fieldset = $form->addFieldset('flurryAnalytics', array('legend' => $this->__('Flurry Analytics')));
     if (isset($data['conf[native][merchantFlurryTracking][isActive]'])) {
         $isActiveValue = $data['conf[native][merchantFlurryTracking][isActive]'];
     } else {
         $isActiveValue = '0';
     }
     $enabled = $fieldset->addField('conf/native/merchantFlurryTracking/isActive', 'select', array('label' => $this->__('Enable Flurry Analytics'), 'name' => 'conf[native][merchantFlurryTracking][isActive]', 'values' => $yesNoValues, 'note' => $this->__('Enable Flurry Analytics for the merchant.'), 'value' => $isActiveValue));
     $flurryAnalyticsUrl = $this->escapeHtml(Mage::getStoreConfig('xmlconnect/flurry_analytics/statistics_url'));
     $fieldset->addField('flurry_analytics_link', 'link', array('title' => $this->__('Flurry Analytics Site'), 'label' => $this->__('Flurry Analytics Site'), 'value' => $flurryAnalyticsUrl, 'href' => $flurryAnalyticsUrl, 'target' => '__blank', 'note' => $this->__('You can watch statistics here.')));
     if (isset($data['conf[native][merchantFlurryTracking][accountId]'])) {
         $accountIdValue = $data['conf[native][merchantFlurryTracking][accountId]'];
     } else {
         $accountIdValue = '';
     }
     $flurryApiCode = $fieldset->addField('conf/native/merchantFlurryTracking/accountId', 'text', array('label' => $this->__('Flurry API Code'), 'name' => 'conf[native][merchantFlurryTracking][accountId]', 'enabled' => true, 'required' => true, 'value' => $accountIdValue));
     // field dependencies
     $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')->addFieldMap($flurryApiCode->getHtmlId(), $flurryApiCode->getName())->addFieldMap($enabled->getHtmlId(), $enabled->getName())->addFieldDependence($flurryApiCode->getName(), $enabled->getName(), 1));
     return parent::_prepareForm();
 }
Пример #14
0
 protected function _beforeToHtml()
 {
     $account = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');
     $magentoOrdersSettings = $account->getData('magento_orders_settings');
     $magentoOrdersSettings = !empty($magentoOrdersSettings) ? json_decode($magentoOrdersSettings, true) : array();
     // ---------------------------------------
     $temp = Mage::getModel('core/website')->getCollection()->setOrder('sort_order', 'ASC')->toArray();
     $this->websites = $temp['items'];
     // ---------------------------------------
     // ---------------------------------------
     $temp = Mage::getModel('customer/group')->getCollection()->toArray();
     $this->groups = $temp['items'];
     // ---------------------------------------
     // ---------------------------------------
     $selectedStore = !empty($magentoOrdersSettings['listing']['store_id']) ? $magentoOrdersSettings['listing']['store_id'] : '';
     $blockStoreSwitcher = $this->getLayout()->createBlock('M2ePro/adminhtml_storeSwitcher', '', array('id' => 'magento_orders_listings_store_id', 'name' => 'magento_orders_settings[listing][store_id]', 'selected' => $selectedStore));
     $blockStoreSwitcher->hasDefaultOption(false);
     $this->setChild('magento_orders_listings_store_id', $blockStoreSwitcher);
     // ---------------------------------------
     // ---------------------------------------
     $selectedStore = !empty($magentoOrdersSettings['listing_other']['store_id']) ? $magentoOrdersSettings['listing_other']['store_id'] : '';
     $blockStoreSwitcher = $this->getLayout()->createBlock('M2ePro/adminhtml_storeSwitcher', '', array('id' => 'magento_orders_listings_other_store_id', 'name' => 'magento_orders_settings[listing_other][store_id]', 'selected' => $selectedStore));
     $blockStoreSwitcher->hasDefaultOption(false);
     $this->setChild('magento_orders_listings_other_store_id', $blockStoreSwitcher);
     // ---------------------------------------
     // ---------------------------------------
     $productTaxClasses = Mage::getModel('tax/class')->getCollection()->addFieldToFilter('class_type', Mage_Tax_Model_Class::TAX_CLASS_TYPE_PRODUCT)->toOptionArray();
     $none = array('value' => Ess_M2ePro_Model_Magento_Product::TAX_CLASS_ID_NONE, 'label' => 'None');
     array_unshift($productTaxClasses, $none);
     $this->productTaxClasses = $productTaxClasses;
     // ---------------------------------------
     return parent::_beforeToHtml();
 }
 public function getSubscriptionObject()
 {
     if (is_null($this->_subscription)) {
         $this->_subscription = Mage::getModel('newsletter/subscriber')->loadByCustomer($this->getCustomer());
     }
     return $this->_subscription;
 }
Пример #16
0
 public function addBlogSection($observer)
 {
     $sitemapObject = $observer->getSitemapObject();
     if (!$sitemapObject instanceof Mage_Sitemap_Model_Sitemap) {
         throw new Exception(Mage::helper('blog')->__('Error during generation sitemap'));
     }
     $storeId = $sitemapObject->getStoreId();
     $date = Mage::getSingleton('core/date')->gmtDate('Y-m-d');
     $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
     /**
      * Generate blog pages sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/blog/changefreq');
     $priority = (string) Mage::getStoreConfig('sitemap/blog/priority');
     $collection = Mage::getModel('blog/blog')->getCollection()->addStoreFilter($storeId);
     Mage::getSingleton('blog/status')->addEnabledFilterToCollection($collection);
     $route = Mage::getStoreConfig('blog/blog/route');
     if ($route == "") {
         $route = "blog";
     }
     foreach ($collection as $item) {
         $xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>', htmlspecialchars($baseUrl . $route . '/' . $item->getIdentifier()), $date, $changefreq, $priority);
         $sitemapObject->sitemapFileAddLine($xml);
     }
     unset($collection);
 }
Пример #17
0
 public function callbackDescription($value, $row, $column, $isExport)
 {
     $fullDescription = Mage::getModel('M2ePro/Log_Abstract')->decodeDescription($row->getData('description'));
     $row->setData('description', $fullDescription);
     $value = $column->getRenderer()->render($row);
     preg_match_all('/href="([^"]*)"/', $fullDescription, $matches);
     if (!count($matches[0])) {
         return $this->prepareLongText($fullDescription, $value);
     }
     foreach ($matches[1] as $key => $href) {
         preg_match_all('/route:([^;]*)/', $href, $routeMatch);
         preg_match_all('/back:([^;]*)/', $href, $backMatch);
         preg_match_all('/filter:([^;]*)/', $href, $filterMatch);
         if (count($routeMatch[1]) == 0) {
             $fullDescription = str_replace($matches[0][$key], '', $fullDescription);
             $value = str_replace($matches[0][$key], '', $value);
             continue;
         }
         $params = array();
         if (count($backMatch[1]) > 0) {
             $params['back'] = Mage::helper('M2ePro')->makeBackUrlParam($backMatch[1][$key]);
         }
         if (count($filterMatch[1]) > 0) {
             $params['filter'] = base64_encode($filterMatch[1][$key]);
         }
         $url = $routeMatch[1][$key];
         $fullDescription = str_replace($href, $this->getUrl($url, $params), $fullDescription);
         $value = str_replace($href, $this->getUrl($url, $params), $value);
     }
     return $this->prepareLongText($fullDescription, $value);
 }
Пример #18
0
 protected function _toHtml()
 {
     $storeId = $this->_getStoreId();
     $newurl = Mage::getUrl('rss/catalog/new/store_id/' . $storeId);
     $title = Mage::helper('rss')->__('New Products from %s', Mage::app()->getStore()->getGroup()->getName());
     $lang = Mage::getStoreConfig('general/locale/code');
     $rssObj = Mage::getModel('rss/rss');
     $data = array('title' => $title, 'description' => $title, 'link' => $newurl, 'charset' => 'UTF-8', 'language' => $lang);
     $rssObj->_addHeader($data);
     /*
     oringinal price - getPrice() - inputed in admin
     special price - getSpecialPrice()
     getFinalPrice() - used in shopping cart calculations
     */
     $product = Mage::getModel('catalog/product');
     $todayDate = $product->getResource()->formatDate(time());
     $products = $product->getCollection()->setStoreId($storeId)->addStoreFilter()->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))->addAttributeToFilter(array(array('attribute' => 'news_to_date', 'date' => true, 'from' => $todayDate), array('attribute' => 'news_to_date', 'is' => new Zend_Db_Expr('null'))), '', 'left')->addAttributeToSort('news_from_date', 'desc')->addAttributeToSelect(array('name', 'short_description', 'description', 'thumbnail'), 'inner')->addAttributeToSelect(array('price', 'special_price', 'special_from_date', 'special_to_date', 'msrp_enabled', 'msrp_display_actual_price_type', 'msrp'), 'left')->applyFrontendPriceLimitations();
     $products->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
     /*
     using resource iterator to load the data one by one
     instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
     */
     Mage::getSingleton('core/resource_iterator')->walk($products->getSelect(), array(array($this, 'addNewItemXmlCallback')), array('rssObj' => $rssObj, 'product' => $product));
     return $rssObj->createRssXml();
 }
Пример #19
0
 /**
  * Preparing default form elements for editing attribute
  *
  * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract
  */
 protected function _prepareForm()
 {
     $attributeObject = $this->getAttributeObject();
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('eav')->__('Attribute Properties')));
     if ($attributeObject->getAttributeId()) {
         $fieldset->addField('attribute_id', 'hidden', array('name' => 'attribute_id'));
     }
     $this->_addElementTypes($fieldset);
     $yesno = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
     $validateClass = sprintf('validate-code validate-length maximum-length-%d', Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH);
     $fieldset->addField('attribute_code', 'text', array('name' => 'attribute_code', 'label' => Mage::helper('eav')->__('Attribute Code'), 'title' => Mage::helper('eav')->__('Attribute Code'), 'note' => Mage::helper('eav')->__('For internal use. Must be unique with no spaces. Maximum length of attribute code must be less then %s symbols', Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH), 'class' => $validateClass, 'required' => true));
     $inputTypes = Mage::getModel('eav/adminhtml_system_config_source_inputtype')->toOptionArray();
     $fieldset->addField('frontend_input', 'select', array('name' => 'frontend_input', 'label' => Mage::helper('eav')->__('Catalog Input Type for Store Owner'), 'title' => Mage::helper('eav')->__('Catalog Input Type for Store Owner'), 'value' => 'text', 'values' => $inputTypes));
     $fieldset->addField('default_value_text', 'text', array('name' => 'default_value_text', 'label' => Mage::helper('eav')->__('Default Value'), 'title' => Mage::helper('eav')->__('Default Value'), 'value' => $attributeObject->getDefaultValue()));
     $fieldset->addField('default_value_yesno', 'select', array('name' => 'default_value_yesno', 'label' => Mage::helper('eav')->__('Default Value'), 'title' => Mage::helper('eav')->__('Default Value'), 'values' => $yesno, 'value' => $attributeObject->getDefaultValue()));
     $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
     $fieldset->addField('default_value_date', 'date', array('name' => 'default_value_date', 'label' => Mage::helper('eav')->__('Default Value'), 'title' => Mage::helper('eav')->__('Default Value'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'value' => $attributeObject->getDefaultValue(), 'format' => $dateFormatIso));
     $fieldset->addField('default_value_textarea', 'textarea', array('name' => 'default_value_textarea', 'label' => Mage::helper('eav')->__('Default Value'), 'title' => Mage::helper('eav')->__('Default Value'), 'value' => $attributeObject->getDefaultValue()));
     $fieldset->addField('is_unique', 'select', array('name' => 'is_unique', 'label' => Mage::helper('eav')->__('Unique Value'), 'title' => Mage::helper('eav')->__('Unique Value (not shared with other products)'), 'note' => Mage::helper('eav')->__('Not shared with other products'), 'values' => $yesno));
     $fieldset->addField('is_required', 'select', array('name' => 'is_required', 'label' => Mage::helper('eav')->__('Values Required'), 'title' => Mage::helper('eav')->__('Values Required'), 'values' => $yesno));
     $fieldset->addField('frontend_class', 'select', array('name' => 'frontend_class', 'label' => Mage::helper('eav')->__('Input Validation for Store Owner'), 'title' => Mage::helper('eav')->__('Input Validation for Store Owner'), 'values' => Mage::helper('eav')->getFrontendClasses($attributeObject->getEntityType()->getEntityTypeCode())));
     if ($attributeObject->getId()) {
         $form->getElement('attribute_code')->setDisabled(1);
         $form->getElement('frontend_input')->setDisabled(1);
         if (!$attributeObject->getIsUserDefined()) {
             $form->getElement('is_unique')->setDisabled(1);
         }
     }
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #20
0
 /**
  *  Export page grid to XML format
  */
 public function exportXmlAction()
 {
     $fileName = 'blocks.xml';
     $blockIds = $this->getRequest()->getParam('block_ids');
     if (!is_array($blockIds)) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
     } else {
         try {
             $collection = Mage::getModel('cms/block')->getCollection()->addFieldToFilter('block_id', array('in' => $blockIds));
             $xml = '<root>';
             $xml .= '<blocks>';
             foreach ($collection as $block) {
                 $xml .= '<cms_block>';
                 $xml .= '<title>' . $block->getTitle() . '</title>';
                 $xml .= '<identifier>' . $block->getIdentifier() . '</identifier>';
                 $xml .= '<content><![CDATA[' . $block->getContent() . ']]></content>';
                 $xml .= '<is_active>' . $block->getIsActive() . '</is_active>';
                 $xml .= '<stores><item>0</item></stores>';
                 $xml .= '</cms_block>';
             }
             $xml .= '</blocks>';
             $xml .= '</root>';
             $this->_sendUploadResponse($fileName, $xml);
         } catch (Exception $e) {
             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
         }
     }
 }
Пример #21
0
 /**
  * @param $quote
  * @return Mage_Sales_Model_Order
  */
 public function convertQuoteToOrder($quote)
 {
     /* @var $service Mage_Sales_Model_Service_Quote */
     $service = Mage::getModel('sales/service_quote', $quote);
     $service->submitAll();
     return $service->getOrder();
 }
Пример #22
0
 /**
  * Prepare url using passed id and return it
  * or return false if path was not found.
  *
  * @return string|false
  */
 public function getHref()
 {
     if (!$this->_href) {
         if ($this->hasStoreId()) {
             $store = Mage::app()->getStore($this->getStoreId());
         } else {
             $store = Mage::app()->getStore();
         }
         $idPath = explode('/', $this->_getData('id_path'));
         if (isset($idPath[0]) && isset($idPath[1]) && $idPath[0] == 'product') {
             /** @var $helper Mage_Catalog_Helper_Product */
             $helper = $this->_getFactory()->getHelper('catalog/product');
             $productId = $idPath[1];
             $categoryId = isset($idPath[2]) ? $idPath[2] : null;
             $this->_href = $helper->getFullProductUrl($productId, $categoryId);
         } elseif (isset($idPath[0]) && isset($idPath[1]) && $idPath[0] == 'category') {
             $categoryId = $idPath[1];
             if ($categoryId) {
                 /** @var $helper Mage_Catalog_Helper_Category */
                 $helper = $this->_getFactory()->getHelper('catalog/category');
                 $category = Mage::getModel('catalog/category')->load($categoryId);
                 $this->_href = $helper->getCategoryUrl($category);
             }
         }
     }
     if ($this->_href) {
         if (strpos($this->_href, "___store") === false) {
             $symbol = strpos($this->_href, "?") === false ? "?" : "&";
             $this->_href = $this->_href . $symbol . "___store=" . $store->getCode();
         }
     } else {
         return false;
     }
     return $this->_href;
 }
Пример #23
0
 public function archivedPosts($showMonths = true)
 {
     $id = $this->getRequest()->getParam('id');
     $collection = Mage::getModel('gallery/gallery')->getCollection()->addFieldToFilter('status', 3)->addFieldToFilter('parent_id', $id);
     $collection->setOrder('created_time ', 'desc');
     $pageSize = Mage::getStoreConfig('gallery/trendsettings/looksperpage');
     if (!$pageSize) {
         $pageSize = 8;
     }
     if ($pageSize != 0) {
         $pager = $this->getLayout()->createBlock('page/html_pager', 'archive.pager');
         $pager->setLimit($pageSize);
         $pager->setTemplate('gallery/pager/archive.phtml');
         $pager->setCollection($collection);
         $this->setChild('pager', $pager);
         $backpager = $this->getLayout()->createBlock('page/html_pager', 'archive.backpager');
         $backpager->setLimit($pageSize);
         $backpager->setTemplate('gallery/pager/backlink.phtml');
         $backpager->setCollection($collection);
         $this->setChild('backpager', $backpager);
         $fwdpager = $this->getLayout()->createBlock('page/html_pager', 'archive.fwdpager');
         $fwdpager->setLimit($pageSize);
         $fwdpager->setTemplate('gallery/pager/fwdlink.phtml');
         $fwdpager->setCollection($collection);
         $this->setChild('fwdpager', $fwdpager);
     }
     //print $collection->getSelect();
     return $collection;
 }
Пример #24
0
 /**
  * Get role registry object or create one
  *
  * @return Mage_Api_Model_Acl_Role_Registry
  */
 protected function _getRoleRegistry()
 {
     if (null === $this->_roleRegistry) {
         $this->_roleRegistry = Mage::getModel('api/acl_role_registry');
     }
     return $this->_roleRegistry;
 }
Пример #25
0
 /**
  * Saving currency rates
  *
  * @param   array $rates
  * @return  Mage_Directory_Model_Currency_Import_Abstract
  */
 protected function _saveRates($rates)
 {
     foreach ($rates as $currencyCode => $currencyRates) {
         Mage::getModel('directory/currency')->setId($currencyCode)->setRates($currencyRates)->save();
     }
     return $this;
 }
Пример #26
0
 /**
  * Assign page to store views
  *
  * @param Mage_Core_Model_Abstract $object
  */
 protected function _afterSave(Mage_Core_Model_Abstract $object)
 {
     $condition = $this->_getWriteAdapter()->quoteInto('post_id = ?', $object->getId());
     // process faq item to store relation
     $this->_getWriteAdapter()->delete($this->getTable('ves_blog/post_store'), $condition);
     $stores = $object->getData('stores');
     if ($stores) {
         foreach ((array) $object->getData('stores') as $store) {
             $storeArray = array();
             $storeArray['post_id'] = $object->getId();
             $storeArray['store_id'] = $store;
             $this->_getWriteAdapter()->insert($this->getTable('ves_blog/post_store'), $storeArray);
         }
     } else {
         $stores = $object->getStoreId();
         if ($stores) {
             foreach ((array) $stores as $store) {
                 $storeArray = array();
                 $storeArray['post_id'] = $object->getId();
                 $storeArray['store_id'] = $store;
                 $this->_getWriteAdapter()->insert($this->getTable('ves_blog/post_store'), $storeArray);
             }
         }
     }
     //Rewrite blog url
     $resroute = Mage::getStoreConfig('ves_blog/general_setting/route');
     $extension = ".html";
     Mage::getModel('core/url_rewrite')->loadByIdPath('venusblog/post/' . $object->getId())->setIdPath('venusblog/post/' . $object->getId())->setRequestPath($resroute . '/' . $object->getIdentifier() . $extension)->setTargetPath('venusblog/post/view/id/' . $object->getId())->save();
     return parent::_afterSave($object);
 }
Пример #27
0
 private function immediatelyNotCheckedProducts()
 {
     $this->getActualOperationHistory()->addTimePoint(__METHOD__, 'Immediately when Product was not checked');
     /** @var $collection Varien_Data_Collection_Db */
     $collection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing_Product');
     $collection->addFieldToFilter('status', Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED);
     $collection->addFieldToFilter('tried_to_list', 0);
     $collection->getSelect()->limit(100);
     $listingsProducts = $collection->getItems();
     /** @var $listingProduct Ess_M2ePro_Model_Listing_Product */
     foreach ($listingsProducts as $listingProduct) {
         $listingProduct->getMagentoProduct()->enableCache();
         $listingProduct->setData('tried_to_list', 1)->save();
         $configurator = Mage::getModel('M2ePro/Buy_Listing_Product_Action_Configurator');
         $isExistInRunner = $this->getRunner()->isExistProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_LIST, $configurator);
         if ($isExistInRunner) {
             continue;
         }
         if (!$this->getInspector()->isMeetListRequirements($listingProduct)) {
             continue;
         }
         $this->getRunner()->addProduct($listingProduct, Ess_M2ePro_Model_Listing_Product::ACTION_LIST, $configurator);
         $this->setListAttemptData($listingProduct);
     }
     $this->getActualOperationHistory()->saveTimePoint(__METHOD__);
 }
Пример #28
0
 protected function getSnapshotNames()
 {
     if (!$this->_snapshotNames) {
         $this->_snapshotNames = Mage::getModel('commercebug/snapshot_name')->getCollection();
     }
     return $this->_snapshotNames;
 }
Пример #29
0
 public function run()
 {
     // prepare
     Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
     // verbose mode?
     $verbose = $this->getArg('verbose');
     $mygassi = $this->getArg('mygassionly');
     $limit = $this->getArg('limit');
     $product = $this->getArg('product');
     if ($limit === false) {
         $limit = 100;
     }
     // check what we're up to
     if ($this->getArg('import')) {
         /** @var $importer Codex_Productimport_Model_Import */
         $importer = Mage::getModel('codex_productimport/import');
         if ($product) {
             $importer->importSingleProduct($product, false);
         } else {
             $importer->importProducts($limit, $mygassi, $verbose);
         }
         // clean image cache
         exec("rm -Rf " . Mage::getBaseDir('media') . '/catalog/product/cache');
     } else {
         if ($this->getArg('dump')) {
             /** @var $importer Codex_Productimport_Model_Import */
             $importer = Mage::getModel('codex_productimport/import');
             $importer->dumpProducts($limit, $mygassi, $verbose, $product);
         } else {
             $this->usageHelp();
         }
     }
 }
Пример #30
0
 /**
  * Setting collection to show
  *
  * @return Mage_Adminhtml_Block_Widget_Grid
  */
 protected function _prepareCollection()
 {
     $collection = Mage::getModel('xmlconnect/queue')->getCollection();
     $collection->addFieldToFilter('main_table.status', array('neq' => Mage_XmlConnect_Model_Queue::STATUS_DELETED));
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }