Пример #1
0
 public function _toHtml()
 {
     if (AO::getStoreConfigFlag('payment/paypaluk_express/active') && AO::getSingleton('checkout/session')->getQuote()->validateMinimumAmount()) {
         return parent::_toHtml();
     }
     return '';
 }
Пример #2
0
 /**
  * Check is enable catalog product for store
  *
  * @param mixed $store
  * @return bool
  */
 public function isEnabled($store = null)
 {
     if (AO::app()->getStore($store)->isAdmin()) {
         return false;
     }
     return AO::getStoreConfigFlag(self::XML_PATH_USE_PRODUCT_FLAT, $store);
 }
Пример #3
0
 /**
  * Generate sitemaps
  *
  * @param Mage_Cron_Model_Schedule $schedule
  */
 public function scheduledGenerateSitemaps($schedule)
 {
     $errors = array();
     // check if scheduled generation enabled
     if (!AO::getStoreConfigFlag(self::XML_PATH_GENERATION_ENABLED)) {
         return;
     }
     $collection = AO::getModel('sitemap/sitemap')->getCollection();
     /* @var $collection Mage_Sitemap_Model_Mysql4_Sitemap_Collection */
     foreach ($collection as $sitemap) {
         /* @var $sitemap Mage_Sitemap_Model_Sitemap */
         try {
             $sitemap->generateXml();
         } catch (Exception $e) {
             $errors[] = $e->getMessage();
         }
     }
     if ($errors && AO::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT)) {
         $translate = AO::getSingleton('core/translate');
         /* @var $translate Mage_Core_Model_Translate */
         $translate->setTranslateInline(false);
         $emailTemplate = AO::getModel('core/email_template');
         /* @var $emailTemplate Mage_Core_Model_Email_Template */
         $emailTemplate->setDesignConfig(array('area' => 'backend'))->sendTransactional(AO::getStoreConfig(self::XML_PATH_ERROR_TEMPLATE), AO::getStoreConfig(self::XML_PATH_ERROR_IDENTITY), AO::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT), null, array('warnings' => join("\n", $errors)));
         $translate->setTranslateInline(true);
     }
 }
Пример #4
0
 public function preDispatch()
 {
     parent::preDispatch();
     if (!AO::getStoreConfigFlag(self::XML_PATH_ENABLED)) {
         $this->norouteAction();
     }
 }
Пример #5
0
 /**
  * Retrieve feed url
  *
  * @return string
  */
 public function getFeedUrl()
 {
     if (is_null($this->_feedUrl)) {
         $this->_feedUrl = AO::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://' . AO::getStoreConfig(self::XML_FEED_URL_PATH);
     }
     return $this->_feedUrl;
 }
Пример #6
0
 public function getConfigFlag($field)
 {
     if (empty($this->_code)) {
         return false;
     }
     $path = 'carriers/' . $this->_code . '/' . $field;
     return AO::getStoreConfigFlag($path, $this->getStore());
 }
Пример #7
0
 /**
  * Return true if flat catalog is enabled, rebuileded and is not Admin
  *
  * @param boolean $skipAdmin
  * @return boolean
  */
 public function isEnabled($skipAdminCheck = false)
 {
     $flatFlag = AO::getStoreConfigFlag(self::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY);
     $isFront = !AO::app()->getStore()->isAdmin();
     if ($skipAdminCheck === true) {
         $isFront = true;
     }
     return (bool) $flatFlag && $isFront;
 }
Пример #8
0
 public function _toHtml()
 {
     if (!AO::getSingleton('checkout/session')->getQuote()->validateMinimumAmount()) {
         return '';
     }
     if (AO::getStoreConfigFlag('google/checkout/active')) {
         return parent::_toHtml();
     }
     return '';
 }
Пример #9
0
 /**
  * Retrieve active system payments
  *
  * @param   mixed $store
  * @return  array
  */
 public function getActiveMethods($store = null)
 {
     $methods = array();
     $config = AO::getStoreConfig('payment', $store);
     foreach ($config as $code => $methodConfig) {
         if (AO::getStoreConfigFlag('payment/' . $code . '/active', $store)) {
             $methods[$code] = $this->_getMethod($code, $methodConfig);
         }
     }
     return $methods;
 }
Пример #10
0
 /**
  * Retrieve active system carriers
  *
  * @param   mixed $store
  * @return  array
  */
 public function getActiveCarriers($store = null)
 {
     $carriers = array();
     $config = AO::getStoreConfig('carriers', $store);
     foreach ($config as $code => $carrierConfig) {
         if (AO::getStoreConfigFlag('carriers/' . $code . '/active', $store)) {
             $carriers[$code] = $this->_getCarrier($code, $carrierConfig, $store);
         }
     }
     return $carriers;
 }
Пример #11
0
 public function getAgreements()
 {
     if (!$this->hasAgreements()) {
         if (!AO::getStoreConfigFlag('checkout/options/enable_agreements')) {
             $agreements = array();
         } else {
             $agreements = AO::getModel('checkout/agreement')->getCollection()->addStoreFilter(AO::app()->getStore()->getId())->addFieldToFilter('is_active', 1);
         }
         $this->setAgreements($agreements);
     }
     return $this->getData('agreements');
 }
Пример #12
0
 /**
  * Load some inventory configuration settings
  *
  */
 protected function _initConfig()
 {
     if (!$this->_isConfig) {
         $this->_isConfig = true;
         $this->_isConfigManageStock = (int) AO::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
         $this->_isConfigBackorders = (int) AO::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_BACKORDERS);
         $this->_configMinQty = (int) AO::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MIN_QTY);
         $this->_configNotifyStockQty = (int) AO::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY);
         $this->_configTypeIds = array_keys(AO::helper('catalogInventory')->getIsQtyTypeIds(true));
         $this->_stock = AO::getModel('cataloginventory/stock');
     }
 }
Пример #13
0
 /**
  * Check is link shareable or not
  *
  * @param Mage_Downloadable_Model_Link | Mage_Downloadable_Model_Link_Purchased_Item $link
  * @return bool
  */
 public function getIsShareable($link)
 {
     $shareable = false;
     switch ($link->getIsShareable()) {
         case Mage_Downloadable_Model_Link::LINK_SHAREABLE_YES:
         case Mage_Downloadable_Model_Link::LINK_SHAREABLE_NO:
             $shareable = (bool) $link->getIsShareable();
             break;
         case Mage_Downloadable_Model_Link::LINK_SHAREABLE_CONFIG:
             $shareable = (bool) AO::getStoreConfigFlag(Mage_Downloadable_Model_Link::XML_PATH_CONFIG_IS_SHAREABLE);
     }
     return $shareable;
 }
Пример #14
0
 public function isAllowed($storeId = null)
 {
     if (is_null($this->_isAllowed)) {
         if ($this->design->getArea() === 'adminhtml') {
             $active = AO::getStoreConfigFlag('dev/translate_inline/active_admin', $storeId);
         } else {
             $active = AO::getStoreConfigFlag('dev/translate_inline/active', $storeId);
         }
         $this->_isAllowed = $active && AO::helper('core')->isDevAllowed($storeId);
     }
     $translate = AO::getSingleton('core/translate');
     /* @var $translate Mage_Core_Model_Translate */
     return $translate->getTranslateInline() && $this->_isAllowed;
 }
Пример #15
0
 public function preDispatch()
 {
     parent::preDispatch();
     if (!AO::getSingleton('customer/session')->authenticate($this)) {
         $this->setFlag('', 'no-dispatch', true);
         if (!AO::getSingleton('customer/session')->getBeforeWishlistUrl()) {
             AO::getSingleton('customer/session')->setBeforeWishlistUrl($this->_getRefererUrl());
         }
     }
     if (!AO::getStoreConfigFlag('wishlist/general/active')) {
         $this->norouteAction();
         return;
     }
 }
Пример #16
0
 protected function _toHtml()
 {
     $newurl = AO::getUrl('rss/catalog/notifystock');
     $title = AO::helper('rss')->__('Low Stock Products');
     $rssObj = AO::getModel('rss/rss');
     $data = array('title' => $title, 'description' => $title, 'link' => $newurl, 'charset' => 'UTF-8');
     $rssObj->_addHeader($data);
     $_configManageStock = (int) AO::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
     $stockItemWhere = "({{table}}.low_stock_date is not null) " . " and ({{table}}.low_stock_date>'0000-00-00') " . " and IF({{table}}.use_config_manage_stock=1," . $_configManageStock . ",{{table}}.manage_stock)=1";
     $product = AO::getModel('catalog/product');
     $collection = $product->getCollection()->addAttributeToSelect('name', true)->addAttributeToSelect('name', true)->joinTable('cataloginventory/stock_item', 'product_id=entity_id', array('qty' => 'qty', 'notify_stock_qty' => 'notify_stock_qty', 'use_config' => 'use_config_notify_stock_qty', 'low_stock_date' => 'low_stock_date'), $stockItemWhere, 'inner')->setOrder('low_stock_date');
     $_globalNotifyStockQty = (double) AO::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY);
     /*
     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.
     */
     AO::getSingleton('core/resource_iterator')->walk($collection->getSelect(), array(array($this, 'addNotifyItemXmlCallback')), array('rssObj' => $rssObj, 'product' => $product, 'globalQty' => $_globalNotifyStockQty));
     return $rssObj->createRssXml();
 }
Пример #17
0
 /**
  * Delete product item from Google Base
  *
  * @param Varien_Object $observer
  * @return Mage_GoogleBase_Model_Observer
  */
 public function deleteProductItem($observer)
 {
     try {
         $product = $observer->getEvent()->getProduct();
         if (AO::getStoreConfigFlag('google/googlebase/observed', $product->getStoreId())) {
             $collection = AO::getResourceModel('googlebase/item_collection')->addProductFilterId($product->getId())->load();
             foreach ($collection as $item) {
                 $item->deleteItem()->delete();
             }
         }
     } catch (Exception $e) {
         if (AO::app()->getStore()->isAdmin()) {
             AO::getSingleton('adminhtml/session')->addNotice(AO::helper('googlebase')->__("Cannot update Google Base Item for Store '%s'", AO::app()->getStore($item->getStoreId())->getName()));
         } else {
             throw $e;
         }
     }
     return $this;
 }
Пример #18
0
 /**
  * Retrieve available payment methods for store
  *
  * array structure:
  *  $index => Varien_Simplexml_Element
  *
  * @param   mixed $store
  * @return  array
  */
 public function getStoreMethods($store = null, $quote = null)
 {
     $methods = AO::getStoreConfig(self::XML_PATH_PAYMENT_METHODS, $store);
     $res = array();
     foreach ($methods as $code => $methodConfig) {
         $prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/';
         if (!AO::getStoreConfigFlag($prefix . 'active', $store)) {
             continue;
         }
         if (!($model = AO::getStoreConfig($prefix . 'model', $store))) {
             continue;
         }
         $methodInstance = AO::getModel($model);
         if ($methodInstance instanceof Mage_Payment_Model_Method_Cc && !AO::getStoreConfig($prefix . 'cctypes')) {
             /* if the payment method has credit card types configuration option
                and no credit card type is enabled in configuration */
             continue;
         }
         if (!$methodInstance->isAvailable($quote)) {
             /* if the payment method can not be used at this time */
             continue;
         }
         $sortOrder = (int) AO::getStoreConfig($prefix . 'sort_order', $store);
         $methodInstance->setSortOrder($sortOrder);
         $methodInstance->setStore($store);
         //            while (isset($res[$sortOrder])) {
         //                $sortOrder++;
         //            }
         //            $res[$sortOrder] = $methodInstance;
         $res[] = $methodInstance;
     }
     //        ksort($res);
     //die('!');
     //echo '<pre>';
     //var_dump( (array)$res);
     usort($res, array($this, '_sortMethods'));
     //var_dump((array)$res);
     //  echo '</pre>';
     return $res;
 }
Пример #19
0
 public function getIsGuestAllowToWrite()
 {
     return AO::getStoreConfigFlag(self::XML_REVIEW_GUETS_ALLOW);
 }
Пример #20
0
 public function canSendCreditmemoCommentEmail($store = null)
 {
     return AO::getStoreConfigFlag(Mage_Sales_Model_Order_Creditmemo::XML_PATH_UPDATE_EMAIL_ENABLED, $store);
 }
Пример #21
0
 /**
  * Return true if target of link new window
  *
  * @return bool
  */
 public function getIsOpenInNewWindow()
 {
     return AO::getStoreConfigFlag(Mage_Downloadable_Model_Link::XML_PATH_TARGET_NEW_WINDOW);
 }
Пример #22
0
 public function isStoreInUrl()
 {
     if (is_null($this->_storeInUrl)) {
         $this->_storeInUrl = AO::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL);
     }
     return $this->_storeInUrl;
 }
Пример #23
0
 protected function _shouldBeSecure($path)
 {
     return substr((string) AO::getConfig()->getNode('default/web/unsecure/base_url'), 0, 5) === 'https' || AO::getStoreConfigFlag('web/secure/use_in_adminhtml', Mage_Core_Model_App::ADMIN_STORE_ID) && substr((string) AO::getConfig()->getNode('default/web/secure/base_url'), 0, 5) === 'https';
 }
Пример #24
0
 /**
  * Check is allowed Guest Checkout
  * Use config settings and observer
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param int|Mage_Core_Model_Store $store
  * @return bool
  */
 public function isAllowedGuestCheckout(Mage_Sales_Model_Quote $quote, $store = null)
 {
     $guestCheckout = AO::getStoreConfigFlag(self::XML_PATH_GUEST_CHECKOUT, $store);
     if ($guestCheckout == true) {
         $result = new Varien_Object();
         $result->setIsAllowed($guestCheckout);
         AO::dispatchEvent('checkout_allow_guest', array('quote' => $quote, 'store' => $store, 'result' => $result));
         $guestCheckout = $result->getIsAllowed();
     }
     return $guestCheckout;
 }
Пример #25
0
 public function cartAction()
 {
     if (AO::getStoreConfigFlag('google/checkout/hide_cart_contents')) {
         $session = AO::getSingleton('checkout/session');
         if ($session->getQuoteId()) {
             $session->getQuote()->delete();
         }
         $session->setQuoteId($session->getGoogleCheckoutQuoteId());
         $session->setGoogleCheckoutQuoteId(null);
     }
     $this->_redirect('checkout/cart');
 }
Пример #26
0
 public function getCssJsHtml()
 {
     //        return '';
     $lines = array();
     $baseJs = AO::getBaseUrl('js');
     $html = '';
     $script = '<script type="text/javascript" src="%s" %s></script>';
     $stylesheet = '<link rel="stylesheet" type="text/css" href="%s" %s />';
     $alternate = '<link rel="alternate" type="%s" href="%s" %s />';
     foreach ($this->_data['items'] as $item) {
         if (!is_null($item['cond']) && !$this->getData($item['cond'])) {
             continue;
         }
         $if = !empty($item['if']) ? $item['if'] : '';
         switch ($item['type']) {
             case 'js':
                 #$lines[$if]['other'][] = sprintf($script, $baseJs.$item['name'], $item['params']);
                 $lines[$if]['script'][] = $item['name'];
                 break;
             case 'js_css':
                 //proxying css will require real-time prepending path to all image urls, should we do it?
                 $lines[$if]['other'][] = sprintf($stylesheet, $baseJs . $item['name'], $item['params']);
                 #$lines[$if]['stylesheet'][] = $item['name'];
                 break;
             case 'skin_js':
                 $lines[$if]['other'][] = sprintf($script, $this->getSkinUrl($item['name']), $item['params']);
                 break;
             case 'skin_css':
                 $lines[$if]['other'][] = sprintf($stylesheet, $this->getSkinUrl($item['name']), $item['params']);
                 break;
             case 'rss':
                 $lines[$if]['other'][] = sprintf($alternate, 'application/rss+xml', $item['name'], $item['params']);
                 break;
         }
     }
     foreach ($lines as $if => $items) {
         if (!empty($if)) {
             $html .= '<!--[if ' . $if . ']>' . "\n";
         }
         if (!empty($items['script'])) {
             $scriptItems = array();
             if (!AO::getStoreConfigFlag('dev/js/deprecation')) {
                 $scriptItems = $this->getChunkedItems($items['script'], 'index.php?c=auto&amp;f=');
             } else {
                 $scriptItems = $items['script'];
             }
             foreach ($scriptItems as $item) {
                 $html .= sprintf($script, $baseJs . $item, '') . "\n";
             }
             //                foreach (array_chunk($items['script'], 15) as $chunk) {
             //                    $html .= sprintf($script, $baseJs.'index.php/x.js?f='.join(',',$chunk), '')."\n";
             //                }
         }
         if (!empty($items['stylesheet'])) {
             foreach ($this->getChunkedItems($items['stylesheet'], $baseJs . 'index.php?c=auto&amp;f=') as $item) {
                 $html .= sprintf($stylesheet, $item, '') . "\n";
             }
             //                foreach (array_chunk($items['stylesheet'], 15) as $chunk) {
             //                    $html .= sprintf($stylesheet, $baseJs.'index.php/x.css?f='.join(',',$chunk), '')."\n";
             //                }
         }
         if (!empty($items['other'])) {
             $html .= join("\n", $items['other']) . "\n";
         }
         if (!empty($if)) {
             $html .= '<![endif]-->' . "\n";
         }
     }
     return $html;
 }
Пример #27
0
 protected function _shouldBeSecure($path)
 {
     return substr(AO::getStoreConfig('web/unsecure/base_url'), 0, 5) === 'https' || AO::getStoreConfigFlag('web/secure/use_in_frontend') && substr(AO::getStoreConfig('web/secure/base_url'), 0, 5) == 'https' && AO::getConfig()->shouldUrlBeSecure($path);
 }
Пример #28
0
 public function getPdf($shipments = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('shipment');
     $pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     $this->_setFontBold($style, 10);
     foreach ($shipments as $shipment) {
         if ($shipment->getStoreId()) {
             AO::app()->getLocale()->emulate($shipment->getStoreId());
         }
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
         $pdf->pages[] = $page;
         $order = $shipment->getOrder();
         /* Add image */
         $this->insertLogo($page, $shipment->getStore());
         /* Add address */
         $this->insertAddress($page, $shipment->getStore());
         /* Add head */
         $this->insertOrder($page, $order, AO::getStoreConfigFlag(self::XML_PATH_SALES_PDF_SHIPMENT_PUT_ORDER_ID, $order->getStoreId()));
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
         $this->_setFontRegular($page);
         $page->drawText(AO::helper('sales')->__('Packingslip # ') . $shipment->getIncrementId(), 35, 780, 'UTF-8');
         /* Add table */
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
         $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
         $page->setLineWidth(0.5);
         /* Add table head */
         $page->drawRectangle(25, $this->y, 570, $this->y - 15);
         $this->y -= 10;
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
         $page->drawText(AO::helper('sales')->__('QTY'), 35, $this->y, 'UTF-8');
         $page->drawText(AO::helper('sales')->__('Products'), 60, $this->y, 'UTF-8');
         $page->drawText(AO::helper('sales')->__('SKU'), 470, $this->y, 'UTF-8');
         $this->y -= 15;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         /* Add body */
         foreach ($shipment->getAllItems() as $item) {
             if ($item->getOrderItem()->getParentItem()) {
                 continue;
             }
             $shift = 10;
             $shift = array();
             if ($this->y < 15) {
                 /* Add new table head */
                 $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
                 $pdf->pages[] = $page;
                 $this->y = 800;
                 $this->_setFontRegular($page);
                 $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
                 $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
                 $page->setLineWidth(0.5);
                 $page->drawRectangle(25, $this->y, 570, $this->y - 15);
                 $this->y -= 10;
                 $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
                 $page->drawText(AO::helper('sales')->__('QTY'), 35, $this->y, 'UTF-8');
                 $page->drawText(AO::helper('sales')->__('Products'), 60, $this->y, 'UTF-8');
                 $page->drawText(AO::helper('sales')->__('SKU'), 470, $this->y, 'UTF-8');
                 $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                 $this->y -= 20;
             }
             /* Draw item */
             $this->_drawItem($item, $page, $order);
         }
     }
     $this->_afterGetPdf();
     if ($shipment->getStoreId()) {
         AO::app()->getLocale()->revert();
     }
     return $pdf;
 }
Пример #29
0
 public function send()
 {
     if (AO::getStoreConfigFlag('system/smtp/disable')) {
         return $this;
     }
     $mail = new Zend_Mail();
     if (strtolower($this->getType()) == 'html') {
         $mail->setBodyHtml($this->getBody());
     } else {
         $mail->setBodyText($this->getBody());
     }
     $mail->setFrom($this->getFromEmail(), $this->getFromName())->addTo($this->getToEmail(), $this->getToName())->setSubject($this->getSubject());
     $mail->send();
     return $this;
 }
Пример #30
0
 /**
  * Copy Product object and assign additional data to the copy
  *
  * @return Mage_GoogleBase_Model_Item
  */
 protected function _prepareProductObject()
 {
     $product = clone $this->getProduct();
     /* @var $product Mage_Catalog_Model_Product */
     $url = $product->getProductUrl(false);
     if (!AO::getStoreConfigFlag('web/url/use_store')) {
         $urlInfo = parse_url($url);
         $store = $product->getStore()->getCode();
         if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
             $url .= '&___store=' . $store;
         } else {
             $url .= '?___store=' . $store;
         }
     }
     $product->setUrl($url)->setQuantity($this->getProduct()->getStockItem()->getQty())->setImageUrl(AO::helper('catalog/product')->getImageUrl($product));
     $this->setProduct($product);
     return $this;
 }