コード例 #1
0
ファイル: Product.php プロジェクト: aligent/cacheobserver
 /**
  * Load a product, implementing specific caching rules
  * @param  Mage_Catalog_Model_Product $oProduct
  * @param  string|int                 $id
  * @param  array                      $attributes
  * @return self
  */
 public function load($oProduct, $id, $attributes = array())
 {
     if (null !== $attributes || !Mage::app()->useCache('catalog_models')) {
         return parent::load($oProduct, $id, $attributes);
     }
     // Caching product data
     Varien_Profiler::start(__METHOD__);
     $storeId = (int) $oProduct->getStoreId();
     $cacheId = "product-{$id}-{$storeId}";
     if ($cacheContent = Mage::app()->loadCache($cacheId)) {
         $data = unserialize($cacheContent);
         if (!empty($data)) {
             $oProduct->setData($data);
         }
     } else {
         parent::load($oProduct, $id, $attributes);
         // You can call some heavy methods here
         try {
             $cacheContent = serialize($oProduct->getData());
             $tags = array(Mage_Catalog_Model_Product::CACHE_TAG, Mage_Catalog_Model_Product::CACHE_TAG . '_' . $id);
             $lifetime = Mage::getStoreConfig('core/cache/lifetime');
             Mage::app()->saveCache($cacheContent, $cacheId, $tags, $lifetime);
         } catch (Exception $e) {
             // Exception = no caching
             Mage::logException($e);
         }
     }
     Varien_Profiler::stop(__METHOD__);
     return $this;
 }
コード例 #2
0
 /**
  * @param Varien_Event_Observer $observer
  *
  * @return $this
  */
 public function handleInlineJs(Varien_Event_Observer $observer)
 {
     Varien_Profiler::start('MeanbeeFooterJs');
     /** @var Meanbee_Footerjs_Helper_Data $helper */
     $helper = Mage::helper('meanbee_footerjs');
     if (!$helper->isEnabled()) {
         return $this;
     }
     /** @var Mage_Core_Block_Abstract $block */
     $block = $observer->getBlock();
     if (!is_null($block->getParentBlock())) {
         // Only look for JS at the root block
         return $this;
     }
     /** @var Varien_Object $transport */
     $transport = $observer->getTransport();
     $patterns = array('js' => self::REGEX_JS, 'document_end' => self::REGEX_DOCUMENT_END);
     foreach ($patterns as $pattern) {
         $matches = array();
         $html = $transport->getHtml();
         $success = preg_match_all($pattern, $html, $matches);
         if ($success) {
             $text = implode('', $matches[0]);
             $html = preg_replace($pattern, '', $html);
             $transport->setHtml($html . $text);
         }
     }
     Varien_Profiler::stop('MeanbeeFooterJs');
     return $this;
 }
コード例 #3
0
ファイル: Price.php プロジェクト: axovel/easycarcare
 /**
  * Calculate product price based on special price data and price rules
  *
  * @param   float $basePrice
  * @param   float $specialPrice
  * @param   string $specialPriceFrom
  * @param   string $specialPriceTo
  * @param   float|null|false $rulePrice
  * @param   mixed $wId
  * @param   mixed $gId
  * @param   null|int $productId
  * @return  float
  */
 public static function calculatePrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo, $rulePrice = false, $wId = null, $gId = null, $productId = null)
 {
     Varien_Profiler::start('__PRODUCT_CALCULATE_PRICE__');
     if ($wId instanceof Mage_Core_Model_Store) {
         $sId = $wId->getId();
         $wId = $wId->getWebsiteId();
     } else {
         $sId = Mage::app()->getWebsite($wId)->getDefaultGroup()->getDefaultStoreId();
     }
     $finalPrice = $basePrice;
     if ($gId instanceof Mage_Customer_Model_Group) {
         $gId = $gId->getId();
     }
     $finalPrice = self::calculateSpecialPrice($finalPrice, $specialPrice, $specialPriceFrom, $specialPriceTo, $sId);
     if ($rulePrice === false) {
         $storeTimestamp = Mage::app()->getLocale()->storeTimeStamp($sId);
         $rulePrice = Mage::getResourceModel('catalogrule/rule')->getRulePrice($storeTimestamp, $wId, $gId, $productId);
     }
     if ($rulePrice !== null && $rulePrice !== false) {
         // THIS LINE WAS CHANGED
         $finalPrice = $rulePrice;
     }
     $finalPrice = max($finalPrice, 0);
     Varien_Profiler::stop('__PRODUCT_CALCULATE_PRICE__');
     return $finalPrice;
 }
 public function getSelectedAttributesInfo($product = null)
 {
     $attributes = array();
     Varien_Profiler::start('CONFIGURABLE:' . __METHOD__);
     if ($attributesOption = $this->getProduct($product)->getCustomOption('attributes')) {
         $data = unserialize($attributesOption->getValue());
         $this->getUsedProductAttributeIds($product);
         $usedAttributes = $this->getProduct($product)->getData($this->_usedAttributes);
         foreach ($data as $attributeId => $attributeValue) {
             if (isset($usedAttributes[$attributeId])) {
                 $attribute = $usedAttributes[$attributeId];
                 $label = $attribute->getLabel();
                 $value = $attribute->getProductAttribute();
                 if ($value->getSourceModel()) {
                     if (Mage::helper('adodis_ajaxcart')->isAjaxCartEnable() && Mage::getStoreConfig('adodis_ajaxcart/qty_settings/cart_page') && (Mage::helper('adodis_ajaxcart')->getIsCartPage() || Mage::helper('adodis_ajaxcart')->getChangeAttributeCart() || Mage::helper('adodis_ajaxcart')->getChangeQtyCart())) {
                         $attribute_values = $attribute->getPrices() ? $attribute->getPrices() : array();
                         foreach ($attribute_values as $_k => $_v) {
                             $attribute_values[$_k]['value'] = $_v['value_index'];
                         }
                         $select = Mage::getSingleton('core/layout')->createBlock('core/html_select')->setClass('glg_cart_attribute_' . $attributeId)->setExtraParams('onchange="AjaxCartConfig.attributeCartChange(this,' . $product->getId() . ')"')->setValue($attributeValue)->setOptions($attribute_values);
                         $value = $select->getHtml();
                     } else {
                         $value = $value->getSource()->getOptionText($attributeValue);
                     }
                 } else {
                     $value = '';
                 }
                 $attributes[] = array('label' => $label, 'value' => $value);
             }
         }
     }
     Varien_Profiler::stop('CONFIGURABLE:' . __METHOD__);
     return $attributes;
 }
コード例 #5
0
 protected function _toHtml()
 {
     $template = AO::getModel('newsletter/template');
     if ($id = (int) $this->getRequest()->getParam('id')) {
         $template->load($id);
     } else {
         $template->setTemplateType($this->getRequest()->getParam('type'));
         $template->setTemplateText($this->getRequest()->getParam('text'));
     }
     if (VPROF) {
         Varien_Profiler::start("email_template_proccessing");
     }
     $vars = array();
     if ($this->getRequest()->getParam('subscriber')) {
         $vars['subscriber'] = AO::getModel('newsletter/subscriber')->load($this->getRequest()->getParam('subscriber'));
     }
     $templateProcessed = $template->getProcessedTemplate($vars, true);
     if ($template->isPlain()) {
         $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
     }
     if (VPROF) {
         Varien_Profiler::stop("email_template_proccessing");
     }
     return $templateProcessed;
 }
コード例 #6
0
 public function sendMail()
 {
     // Set sender information
     $senderName = Mage::helper('abandonedrecover/config')->getSenderName();
     $senderEmail = Mage::helper('abandonedrecover/config')->getSenderEmail();
     // Get Store ID
     $storeId = Mage::app()->getStore()->getId();
     $template = Mage::getModel('core/email_template');
     $emailTemplateId = Mage::helper('abandonedrecover/config')->getEmailTemplateId();
     $modelEmailTemplate = Mage::getModel('adminhtml/email_template')->load($emailTemplateId);
     $template->setTemplateStyles($modelEmailTemplate->getTemplateStyles());
     $template->setTemplateText($modelEmailTemplate->getTemplateText());
     $host = Mage::helper('abandonedrecover/config')->getHost();
     $subject = $modelEmailTemplate->getTemplateSubject();
     $collection = Mage::getResourceModel('reports/quote_collection');
     $storeIds = Mage::app()->getStore()->getId();
     $collection->prepareForAbandonedReport($storeIds);
     foreach ($collection as $item) {
         $vars = array();
         $reception = array();
         $reception['fromemail'] = $senderEmail;
         $reception['fromname'] = $senderName;
         $reception['toemail'] = $item->getCustomerEmail();
         $reception['toname'] = $item->getCustomerName();
         $vars['order'] = $item;
         $vars['abandoned_customer'] = $item;
         $template->setDesignConfig(array('area' => 'frontend', 'store' => $storeId));
         Varien_Profiler::start("email_template_proccessing");
         $templateProcessed = $template->getProcessedTemplate($vars, true);
         Varien_Profiler::stop("email_template_proccessing");
         Mage::helper('abandonedrecover')->sendMail($host, $subject, $templateProcessed, $reception);
     }
     return true;
 }
コード例 #7
0
ファイル: Package.php プロジェクト: ngreimel/mci
 /**
  * Get skin file url
  * -- Mod: Add file modification time to URL for caching purposes
  *
  * @param string $file
  * @param array $params
  * @return string
  */
 public function getSkinUrl($file = null, array $params = array())
 {
     Varien_Profiler::start(__METHOD__);
     if (empty($params['_type'])) {
         $params['_type'] = 'skin';
     }
     if (empty($params['_default'])) {
         $params['_default'] = false;
     }
     $this->updateParamDefaults($params);
     if (!empty($file)) {
         $result = $this->_fallback($file, $params, array(array(), array('_theme' => $this->getFallbackTheme()), array('_theme' => self::DEFAULT_THEME)));
     }
     if (!empty($file)) {
         $filename = $this->getFilename($file, array('_type' => 'skin'));
         if (file_exists($filename)) {
             $path = pathinfo($file);
             if (array_key_exists('extension', $path) && in_array($path['extension'], array('css', 'js', 'png', 'jpg', 'gif'))) {
                 $mtime = filemtime($filename);
                 $file = ($path['dirname'] != '.' ? $path['dirname'] . DS : '') . $path['filename'] . '.' . $mtime . '.' . $path['extension'];
             }
         }
     }
     $result = $this->getSkinBaseUrl($params) . (empty($file) ? '' : $file);
     Varien_Profiler::stop(__METHOD__);
     return $result;
 }
コード例 #8
0
 /**
  * Prepare the feed file and returns its path
  *
  * @param array $productsData
  * @param int $storeId
  * @return string
  */
 public function prepareFeed(array $productsData, $storeId)
 {
     $mId = $this->getVendorConfig('merchant_id', $storeId);
     $company = $this->getVendorConfig('company', $storeId);
     if (!$mId || !$company) {
         Mage::throwException(Mage::helper('productfeed')->__('LinkShare Merchant ID and Company Name must be set.'));
     }
     Varien_Profiler::start('productfeed_' . $this->getVendorCode() . '::' . __FUNCTION__);
     $content = implode(self::DELIMITER, array('HDR', $mId, $company, Mage::getModel('core/date')->date('Y-m-d/H:i:s'))) . self::EOL;
     foreach ($productsData as $row) {
         $content .= $row . self::EOL;
     }
     $filename = $mId . '_nmerchandis' . Mage::getModel('core/date')->date('Ymd') . '.txt';
     $filepath = $this->getFeedStorageDir() . $filename;
     try {
         $ioAdapter = new Varien_Io_File();
         $ioAdapter->setAllowCreateFolders(true);
         $ioAdapter->createDestinationDir($this->getFeedStorageDir());
         $ioAdapter->cd($this->getFeedStorageDir());
         $ioAdapter->streamOpen($filename);
         $ioAdapter->streamWrite($content);
         Varien_Profiler::stop('productfeed_' . $this->getVendorCode() . '::' . __FUNCTION__);
         return $filepath;
     } catch (Exception $e) {
         Varien_Profiler::stop('productfeed_' . $this->getVendorCode() . '::' . __FUNCTION__);
         Mage::throwException(Mage::helper('productfeed')->__('Could not write feed file to path: %s, %s', $filepath, $e->getMessage()));
     }
 }
コード例 #9
0
ファイル: Varien.php プロジェクト: arslbbt/mangentovies
 public function start($sessionName = null)
 {
     if (isset($_SESSION)) {
         return $this;
     }
     Varien_Profiler::start(__METHOD__ . '/setOptions');
     if (is_writable(Mage::getBaseDir('session'))) {
         session_save_path(Mage::getBaseDir('session'));
     }
     Varien_Profiler::stop(__METHOD__ . '/setOptions');
     session_module_name('files');
     /*
             $sessionResource = Mage::getResourceSingleton('core/session');
             $sessionResource->setSaveHandler();
     */
     if ($this->getCookieLifetime() !== null) {
         ini_set('session.gc_maxlifetime', $this->getCookieLifetime());
     }
     if ($this->getCookiePath() !== null) {
         ini_set('session.cookie_path', $this->getCookiePath());
     }
     if ($this->getCookieDomain() !== null) {
         ini_set('session.cookie_domain', $this->getCookieDomain());
     }
     if (!empty($sessionName)) {
         session_name($sessionName);
     }
     // potential custom logic for session id (ex. switching between hosts)
     $this->setSessionId();
     Varien_Profiler::start(__METHOD__ . '/start');
     session_start();
     Varien_Profiler::stop(__METHOD__ . '/start');
     return $this;
 }
コード例 #10
0
ファイル: hoimport.php プロジェクト: tormit/Ho_Import
 /**
  * Run script
  *
  * @return void
  */
 public function run()
 {
     Mage::helper('ho_import/log')->setMode('cli');
     $action = $this->getArg('action');
     if (empty($action)) {
         echo $this->usageHelp();
     } else {
         Varien_Profiler::start("shell-productimport" . $this->getArg('action'));
         //disable the inline translator for the cli, breaks the import if it is enabled.
         Mage::getConfig()->setNode('stores/admin/dev/translate_inline/active', 0);
         //initialize the translations so that we are able to translate things.
         Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_TRANSLATE);
         $actionMethodName = $action . 'Action';
         if (method_exists($this, $actionMethodName)) {
             $this->{$actionMethodName}();
         } else {
             echo "Action {$action} not found!\n";
             echo $this->usageHelp();
             exit(1);
         }
         Varien_Profiler::stop("shell-productimport-" . $this->getArg('action'));
         /** @var $profiler Aoe_Profiler_Helper_Data */
         if (Mage::helper('core')->isModuleEnabled('aoe_profiler') && ($profiler = Mage::helper('aoe_profiler') && $this->getArg('profiler') == '1')) {
             $profiler->renderProfilerOutputToFile();
         }
     }
 }
コード例 #11
0
ファイル: Package.php プロジェクト: sixg/mkAnagh
 /**
  * Use this one to get existing file name with fallback to default
  *
  * $params['_type'] is required
  *
  * @param string $file
  * @param array $params
  * @return string
  */
 public function getFilename($file, array $params)
 {
     Varien_Profiler::start(__METHOD__);
     $this->updateParamDefaults($params);
     $module = Mage::app()->getRequest()->getRequestedRouteName();
     $controller = Mage::app()->getRequest()->getRequestedControllerName();
     $action = Mage::app()->getRequest()->getRequestedActionName();
     $exceptionblocks = '';
     $exceptionblocks = Mage::app()->getConfig()->getNode(self::XML_PATH_CED_REWRITES . "/" . $module . "/" . $controller . "/" . $action);
     if (strlen($exceptionblocks) == 0) {
         $action = "all";
         $exceptionblocks = Mage::app()->getConfig()->getNode(self::XML_PATH_CED_REWRITES . "/" . $module . "/" . $controller . "/" . $action);
     }
     if (strlen($exceptionblocks) > 0) {
         $exceptionblocks = explode(",", $exceptionblocks);
         if (count($exceptionblocks) > 0 && $params['_area'] == "adminhtml" && ($params['_package'] !== "default" || $params['_theme'] !== "default")) {
             $params['_package'] = 'default';
             if (Mage::helper('core')->isModuleEnabled('Ced_CsVendorPanel')) {
                 $params['_theme'] = 'ced';
             } else {
                 $params['_theme'] = 'default';
             }
         }
     }
     if (version_compare(Mage::getVersion(), '1.8.1.0', '<=')) {
         $result = $this->_fallback($file, $params, array(array(), array('_theme' => $this->getFallbackTheme()), array('_theme' => self::DEFAULT_THEME)));
     } else {
         $result = $this->_fallback($file, $params, $this->_fallback->getFallbackScheme($params['_area'], $params['_package'], $params['_theme']));
     }
     Varien_Profiler::stop(__METHOD__);
     return $result;
 }
コード例 #12
0
ファイル: Product.php プロジェクト: rajarshc/Rooja
 public function updateCatalogRulesHash($observer)
 {
     Varien_Profiler::start("TBT_Rewards:: Update rewards rule information on product(s)");
     //Mage::log("Update rewards rule information on product(s)");
     //@nelkaake Friday March 12, 2010 03:48:20 PM : Was this was a product save/delete/update request?
     //@nelkaake Changed on Wednesday September 29, 2010: Some Magento stores dont parse the controller action properly so it applies all rules on save.  Fixed by checking passed product
     $target_product_id = null;
     $action = $observer->getControllerAction();
     if ($action) {
         $request = $action->getRequest();
         $target_product_id = $request->getParam("id");
         if (!$target_product_id) {
             $target_product_id = null;
         }
         //if no product id available, reset our assumption because this must be some other unrecognized request.
     }
     $product = $observer->getProduct();
     if ($product) {
         $target_product_id = $product->getEntityId();
         if (!$target_product_id) {
             $target_product_id = null;
         }
         //if no product id
         //available, reset our assumption because this must be some other
         //unrecognized request.
     }
     //@nelkaake Changed on Wednesday September 22, 2010:
     $this->updateRulesHashForDay(Mage::helper('rewards/datetime')->yesterday(), $target_product_id);
     $this->updateRulesHashForDay(Mage::helper('rewards/datetime')->now(), $target_product_id);
     $this->updateRulesHashForDay(Mage::helper('rewards/datetime')->tomorrow(), $target_product_id);
     Varien_Profiler::stop("TBT_Rewards:: Update rewards rule information on product(s)");
     return $this;
 }
コード例 #13
0
 protected function _beforeToHtml()
 {
     /*
             if (Mage::registry('current_customer')->getId()) {
                 $this->addTab('view', array(
                     'label'     => Mage::helper('customer')->__('Customer View'),
                     'content'   => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_view')->toHtml(),
                     'active'    => true
                 ));
             }
     */
     $this->addTab('account', array('label' => Mage::helper('customer')->__('Account Information'), 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_account')->initForm()->toHtml(), 'active' => Mage::registry('current_customer')->getId() ? false : true));
     $this->addTab('addresses', array('label' => Mage::helper('customer')->__('Addresses'), 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_addresses')->initForm()->toHtml()));
     // load: Orders, Shopping Cart, Wishlist, Product Reviews, Product Tags - with ajax
     if (Mage::registry('current_customer')->getId()) {
         if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
             $this->addTab('orders', array('label' => Mage::helper('customer')->__('Orders'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/orders', array('_current' => true))));
         }
         $this->addTab('cart', array('label' => Mage::helper('customer')->__('Shopping Cart'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/carts', array('_current' => true))));
         $this->addTab('wishlist', array('label' => Mage::helper('customer')->__('Wishlist'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/wishlist', array('_current' => true))));
         if (Mage::getSingleton('admin/session')->isAllowed('newsletter/subscriber')) {
             $this->addTab('newsletter', array('label' => Mage::helper('customer')->__('Newsletter'), 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_newsletter')->initForm()->toHtml()));
         }
         if (Mage::getSingleton('admin/session')->isAllowed('catalog/reviews_ratings')) {
             $this->addTab('reviews', array('label' => Mage::helper('customer')->__('Product Reviews'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/productReviews', array('_current' => true))));
         }
         if (Mage::getSingleton('admin/session')->isAllowed('catalog/tag')) {
             $this->addTab('tags', array('label' => Mage::helper('customer')->__('Product Tags'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/productTags', array('_current' => true))));
         }
     }
     $this->_updateActiveTab();
     Varien_Profiler::stop('customer/tabs');
     return parent::_beforeToHtml();
 }
コード例 #14
0
 /**
  * Retrieve regions data json
  *
  * @return string
  */
 public function getRegionJson()
 {
     Varien_Profiler::start('TEST: ' . __METHOD__);
     if (!$this->_regionJson) {
         $cacheKey = 'DIRECTORY_REGIONS_JSON_STORE' . Mage::app()->getStore()->getId();
         if (Mage::app()->useCache('config')) {
             $json = Mage::app()->loadCache($cacheKey);
         }
         if (empty($json)) {
             $countryIds = array();
             foreach ($this->getCountryCollection() as $country) {
                 $countryIds[] = $country->getCountryId();
             }
             $collection = Mage::getModel('directory/region')->getResourceCollection()->addCountryFilter($countryIds)->load();
             $regions = array();
             foreach ($collection as $region) {
                 if (!$region->getRegionId()) {
                     continue;
                 }
                 $regions[$region->getCountryId()][$region->getRegionId()] = array('code' => $region->getCode(), 'name' => $region->getName());
             }
             $json = Mage::helper('core')->jsonEncode($regions);
             if (Mage::app()->useCache('config')) {
                 Mage::app()->saveCache($json, $cacheKey, array('config'));
             }
         }
         $this->_regionJson = $json;
     }
     Varien_Profiler::stop('TEST: ' . __METHOD__);
     return $this->_regionJson;
 }
コード例 #15
0
ファイル: Tabs.php プロジェクト: rajarshc/Rooja
 /**
  * This overwrites the parent function to add the 'Points & Rewards' 
  * tab in the edit menu for the customer.
  * 
  */
 protected function _beforeToHtml()
 {
     if (Mage::registry('current_customer')->getId()) {
         $this->addTab('view', array('label' => Mage::helper('customer')->__('Customer View'), 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_view')->toHtml(), 'active' => true));
     }
     $this->addTab('account', array('label' => Mage::helper('customer')->__('Account Information'), 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_account')->initForm()->toHtml(), 'active' => Mage::registry('current_customer')->getId() ? false : true));
     $this->addTab('addresses', array('label' => Mage::helper('customer')->__('Addresses'), 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_addresses')->initForm()->toHtml()));
     // load: Orders, Shopping Cart, Wishlist, Product Reviews, Product Tags - with ajax
     if (Mage::registry('current_customer')->getId()) {
         $this->addTab('orders', array('label' => Mage::helper('customer')->__('Orders'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/orders', array('_current' => true))));
         $this->addTab('cart', array('label' => Mage::helper('customer')->__('Shopping Cart'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/carts', array('_current' => true))));
         $this->addTab('wishlist', array('label' => Mage::helper('customer')->__('Wishlist'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/wishlist', array('_current' => true))));
         $this->addTab('newsletter', array('label' => Mage::helper('customer')->__('Newsletter'), 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_newsletter')->initForm()->toHtml()));
         $this->addTab('reviews', array('label' => Mage::helper('customer')->__('Product Reviews'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/productReviews', array('_current' => true))));
         $this->addTab('tags', array('label' => Mage::helper('customer')->__('Product Tags'), 'class' => 'ajax', 'url' => $this->getUrl('*/*/productTags', array('_current' => true))));
         $this->addTab('rewards', array('label' => Mage::helper('customer')->__('Points & Rewards'), 'content' => $this->getLayout()->createBlock('rewards/manage_customer_edit_tab_main')->toHtml()));
     }
     $this->_updateActiveTab();
     Varien_Profiler::stop('customer/tabs');
     return parent::_beforeToHtml();
     //    	$html = parent::_beforeToHtml();
     //        if (Mage::registry('current_customer')->getId()) {
     //        }
     //
     //        $this->_updateActiveTab();
     ////        Varien_Profiler::stop('customer/tabs');
     //        return $html;
 }
コード例 #16
0
ファイル: Image.php プロジェクト: technomagegithub/olgo.nl
 public function toStr()
 {
     Varien_Profiler::start(__CLASS__ . '::' . __FUNCTION__);
     // try {
     if ($this->getImageFile()) {
         $this->_getModel()->setBaseFile($this->getImageFile());
     } else {
         $this->_getModel()->setBaseFile($this->getItem()->getData($this->_getModel()->getDestinationSubdir()));
     }
     if ($this->_getModel()->isCached()) {
         return $this->_getModel()->getUrl();
     } else {
         if ($this->_scheduleRotate) {
             $this->_getModel()->rotate($this->getAngle());
         }
         if ($this->_scheduleResize) {
             $this->_getModel()->resize();
         }
         if ($this->_scheduleCrop) {
             $this->_getModel()->crop();
         }
         if ($this->getWatermark()) {
             $this->_getModel()->setWatermark($this->getWatermark());
         }
         $url = $this->_getModel()->saveFile()->getUrl();
     }
     // } catch (Mage_Exception $e) {
     //     $url = Mage::getDesign()->getSkinUrl($this->getPlaceholder());
     // }
     Varien_Profiler::stop(__CLASS__ . '::' . __FUNCTION__);
     return $url;
 }
コード例 #17
0
ファイル: Data.php プロジェクト: mygento/minify
 /**
  * Merge specified files into one
  *
  * By default will not merge, if there is already merged file exists and it
  * was modified after its components
  * If target file is specified, will attempt to write merged contents into it,
  * otherwise will return merged content
  * May apply callback to each file contents. Callback gets parameters:
  * (<existing system filename>, <file contents>)
  * May filter files by specified extension(s)
  * Returns false on error
  *
  * @param array $srcFiles
  * @param string|false $targetFile - file path to be written
  * @param bool $mustMerge
  * @param callback $beforeMergeCallback
  * @param array|string $extensionsFilter
  * @return bool|string
  */
 public function mergeFiles(array $srcFiles, $targetFile = false, $mustMerge = false, $beforeMergeCallback = null, $extensionsFilter = array())
 {
     $content_type = pathinfo($targetFile, PATHINFO_EXTENSION);
     if (!Mage::getStoreConfig('minify/general/enabled') || $content_type != 'css' && $content_type != 'js') {
         return parent::mergeFiles($srcFiles, $targetFile, $mustMerge, $beforeMergeCallback, $extensionsFilter);
     }
     if (!Mage::getStoreConfig('minify/general/' . $content_type)) {
         return parent::mergeFiles($srcFiles, $targetFile, $mustMerge, $beforeMergeCallback, $extensionsFilter);
     }
     try {
         $shouldMinify = $this->shouldMinify($mustMerge, $targetFile, $srcFiles);
         if ($shouldMinify) {
             $result = parent::mergeFiles($srcFiles, false, $mustMerge, $beforeMergeCallback, $extensionsFilter);
             Varien_Profiler::start('minify_file_' . $targetFile);
             switch ($content_type) {
                 case 'css':
                     $minifier = new MatthiasMullie\Minify\CSS($result);
                     break;
                 case 'js':
                     $minifier = new MatthiasMullie\Minify\JS($result);
                     break;
             }
             $minifier->minify($targetFile);
             Varien_Profiler::stop('minify_file_' . $targetFile);
         }
         return true;
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return false;
 }
コード例 #18
0
ファイル: Template.php プロジェクト: huguesalary/Magento-Twig
 /**
  * Retrieve block view from file (template)
  *
  * @param   string $fileName
  * @return  string
  */
 public function fetchView($fileName)
 {
     Varien_Profiler::start($fileName);
     extract($this->_viewVars);
     $do = $this->getDirectOutput();
     if (!$do) {
         ob_start();
     }
     if ($this->getShowTemplateHints()) {
         echo '<div style="position:relative; border:1px dotted red; margin:6px 2px; padding:18px 2px 2px 2px; zoom:1;"><div style="position:absolute; left:0; top:0; padding:2px 5px; background:red; color:white; font:normal 11px Arial; text-align:left !important; z-index:998;" onmouseover="this.style.zIndex=\'999\'" onmouseout="this.style.zIndex=\'998\'" title="' . $fileName . '">' . $fileName . '</div>';
         if (self::$_showTemplateHintsBlocks) {
             $thisClass = get_class($this);
             echo '<div style="position:absolute; right:0; top:0; padding:2px 5px; background:red; color:blue; font:normal 11px Arial; text-align:left !important; z-index:998;" onmouseover="this.style.zIndex=\'999\'" onmouseout="this.style.zIndex=\'998\'" title="' . $thisClass . '">' . $thisClass . '</div>';
         }
     }
     try {
         $template = $this->_twig->loadTemplate($fileName);
         echo $template->render($this->_viewVars);
     } catch (Exception $e) {
         ob_get_clean();
         throw $e;
     }
     if ($this->getShowTemplateHints()) {
         echo '</div>';
     }
     if (!$do) {
         $html = ob_get_clean();
     } else {
         $html = '';
     }
     Varien_Profiler::stop($fileName);
     return $html;
 }
コード例 #19
0
 public function getUsedProducts($requiredAttributeIds = null, $product = null)
 {
     Varien_Profiler::start('CONFIGURABLE:' . __METHOD__);
     if (!$this->getProduct($product)->hasData($this->_usedProducts)) {
         if (is_null($requiredAttributeIds) and is_null($this->getProduct($product)->getData($this->_configurableAttributes))) {
             // If used products load before attributes, we will load attributes.
             $this->getConfigurableAttributes($product);
             // After attributes loading products loaded too.
             Varien_Profiler::stop('CONFIGURABLE:' . __METHOD__);
             return $this->getProduct($product)->getData($this->_usedProducts);
         }
         $usedProducts = array();
         $collection = $this->getUsedProductCollection($product)->addAttributeToSelect('*')->addFilterByRequiredOptions();
         if (is_array($requiredAttributeIds)) {
             foreach ($requiredAttributeIds as $attributeId) {
                 $attribute = $this->getAttributeById($attributeId, $product);
                 if (!is_null($attribute)) {
                     $collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull' => 1));
                 }
             }
         }
         foreach ($collection as $item) {
             $usedProducts[] = $item;
         }
         $this->getProduct($product)->setData($this->_usedProducts, $usedProducts);
     }
     Varien_Profiler::stop('CONFIGURABLE:' . __METHOD__);
     return $this->getProduct($product)->getData($this->_usedProducts);
 }
コード例 #20
0
 /**
  * @param Varien_Event_Observer $observer
  *
  * @return $this
  */
 public function handleInlineJs(Varien_Event_Observer $observer)
 {
     Varien_Profiler::start('MeanbeeFooterJs');
     /** @var Meanbee_Footerjs_Helper_Data $helper */
     $helper = Mage::helper('meanbee_footerjs');
     if (!$helper->isEnabled()) {
         return $this;
     }
     /** @var Mage_Core_Controller_Response_Http $response */
     $response = $observer->getResponse();
     if (!$response->getBody()) {
         // No further action if no body, e.g. redirect
         return $this;
     }
     $patterns = array('js' => self::REGEX_JS, 'document_end' => self::REGEX_DOCUMENT_END);
     foreach ($patterns as $pattern) {
         $matches = array();
         $html = $response->getBody();
         $success = preg_match_all($pattern, $html, $matches);
         if ($success) {
             $text = implode('', $matches[0]);
             $html = preg_replace($pattern, '', $html);
             $response->setBody($html . $text);
         }
     }
     Varien_Profiler::stop('MeanbeeFooterJs');
     return $this;
 }
コード例 #21
0
ファイル: Profiler.php プロジェクト: SalesOneGit/s1_magento
 protected function _toHtml()
 {
     if (!$this->_beforeToHtml() || !Mage::getStoreConfig('dev/debug/profiler') || !Mage::helper('core')->isDevAllowed()) {
         return '';
     }
     $timers = Varien_Profiler::getTimers();
     #$out = '<div style="position:fixed;bottom:5px;right:5px;opacity:.1;background:white" onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=.1">';
     #$out = '<div style="opacity:.1" onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=.1">';
     $out = "<a href=\"javascript:void(0)\" onclick=\"\$('profiler_section').style.display=\$('profiler_section').style.display==''?'none':''\">[profiler]</a>";
     $out .= '<div id="profiler_section" style="background:white; display:block">';
     $out .= '<pre>Memory usage: real: ' . memory_get_usage(true) . ', emalloc: ' . memory_get_usage() . '</pre>';
     $out .= '<table border="1" cellspacing="0" cellpadding="2" style="width:auto">';
     $out .= '<tr><th>Code Profiler</th><th>Time</th><th>Cnt</th><th>Emalloc</th><th>RealMem</th></tr>';
     foreach ($timers as $name => $timer) {
         $sum = Varien_Profiler::fetch($name, 'sum');
         $count = Varien_Profiler::fetch($name, 'count');
         $realmem = Varien_Profiler::fetch($name, 'realmem');
         $emalloc = Varien_Profiler::fetch($name, 'emalloc');
         if ($sum < 0.001 && $count < 10 && $emalloc < 10000) {
             continue;
         }
         $out .= '<tr>' . '<td align="left">' . $name . '</td>' . '<td>' . number_format($sum, 4) . '</td>' . '<td align="right">' . $count . '</td>' . '<td align="right">' . number_format($emalloc) . '</td>' . '<td align="right">' . number_format($realmem) . '</td>' . '</tr>';
     }
     $out .= '</table>';
     $out .= '<pre>';
     $out .= print_r(Varien_Profiler::getSqlProfiler(Mage::getSingleton('core/resource')->getConnection('core_write')), 1);
     $out .= '</pre>';
     $out .= '</div>';
     return $out;
 }
コード例 #22
0
ファイル: Preview.php プロジェクト: SalesOneGit/s1_magento
 protected function _toHtml()
 {
     /* @var $template Mage_Newsletter_Model_Template */
     $template = Mage::getModel('newsletter/template');
     if ($id = (int) $this->getRequest()->getParam('id')) {
         $queue = Mage::getModel('newsletter/queue');
         $queue->load($id);
         $template->setTemplateType($queue->getNewsletterType());
         $template->setTemplateText($queue->getNewsletterText());
         $template->setTemplateStyles($queue->getNewsletterStyles());
     } else {
         $template->setTemplateType($this->getRequest()->getParam('type'));
         $template->setTemplateText($this->getRequest()->getParam('text'));
         $template->setTemplateStyles($this->getRequest()->getParam('styles'));
     }
     $storeId = (int) $this->getRequest()->getParam('store_id');
     if (!$storeId) {
         $storeId = Mage::app()->getAnyStoreView()->getId();
     }
     Varien_Profiler::start("newsletter_queue_proccessing");
     $vars = array();
     $vars['subscriber'] = Mage::getModel('newsletter/subscriber');
     $template->emulateDesign($storeId);
     $templateProcessed = $template->getProcessedTemplate($vars, true);
     $template->revertDesign();
     if ($template->isPlain()) {
         $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
     }
     Varien_Profiler::stop("newsletter_queue_proccessing");
     return $templateProcessed;
 }
コード例 #23
0
 /**
  * Prepare html output
  *
  * @return string
  */
 protected function _toHtml()
 {
     // Start store emulation process
     // Since the Transactional Email preview process has no mechanism for selecting a store view to use for
     // previewing, use the default store view
     $defaultStoreId = Mage::app()->getDefaultStoreView()->getId();
     $appEmulation = Mage::getSingleton('core/app_emulation');
     $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($defaultStoreId);
     /** @var $template Mage_Core_Model_Email_Template */
     $template = Mage::getModel('core/email_template');
     $id = (int) $this->getRequest()->getParam('id');
     if ($id) {
         $template->load($id);
     } else {
         $template->setTemplateType($this->getRequest()->getParam('type'));
         $template->setTemplateText($this->getRequest()->getParam('text'));
         $template->setTemplateStyles($this->getRequest()->getParam('styles'));
     }
     /* @var $filter Mage_Core_Model_Input_Filter_MaliciousCode */
     $filter = Mage::getSingleton('core/input_filter_maliciousCode');
     $template->setTemplateText($filter->filter($template->getTemplateText()));
     Varien_Profiler::start("email_template_proccessing");
     $vars = array();
     $templateProcessed = $template->getProcessedTemplate($vars, true);
     if ($template->isPlain()) {
         $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
     }
     Varien_Profiler::stop("email_template_proccessing");
     // Stop store emulation process
     $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
     return $templateProcessed;
 }
コード例 #24
0
 public function load($printQuery = false, $logQuery = false)
 {
     Varien_Profiler::start("aw::advancedreports::aggregator::load_collection");
     parent::load($printQuery, $logQuery);
     Varien_Profiler::stop("aw::advancedreports::aggregator::load_collection");
     return $this;
 }
コード例 #25
0
ファイル: Data.php プロジェクト: mygento/minify
 /**
  * Minify the data
  *
  * @param  string $path Path to read-write the data to.
  * @param  string $type Content-Type
  */
 public function minifyFile($path, $type)
 {
     Varien_Profiler::start('minify_file_' . $path);
     $minifier = $this->getMinifier($path, $type);
     $minifier->minify($path . '.min');
     Varien_Profiler::stop('minify_file_' . $path);
 }
コード例 #26
0
ファイル: Configurable.php プロジェクト: cnglobal-sl/caterez
 /**
  * Retrieve Selected Attributes info
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getSelectedAttributesInfoId($product = null)
 {
     $attributes = array();
     Varien_Profiler::start('CONFIGURABLE:' . __METHOD__);
     if ($attributesOption = $this->getProduct($product)->getCustomOption('attributes')) {
         $data = unserialize($attributesOption->getValue());
         $this->getUsedProductAttributeIds($product);
         $usedAttributes = $this->getProduct($product)->getData($this->_usedAttributes);
         foreach ($data as $attributeId => $attributeValue) {
             if (isset($usedAttributes[$attributeId])) {
                 $attribute = $usedAttributes[$attributeId];
                 //$label = $attribute->getLabel();
                 $label = $attribute->getAttributeId();
                 $value = $attribute->getProductAttribute();
                 if ($value->getSourceModel()) {
                     //$value = $value->getSource()->getOptionText($attributeValue);
                     $value = $value->getSource()->getOptionId($attributeValue);
                 } else {
                     $value = '';
                 }
                 //$attributes[] = array('label'=>$label, 'value'=>$value);
                 $attributes[$label] = $value;
             }
         }
     }
     Varien_Profiler::stop('CONFIGURABLE:' . __METHOD__);
     return $attributes;
 }
コード例 #27
0
ファイル: Tree.php プロジェクト: unifiedarts/Aoe_Profiler
 /**
  * Render tree (recursive function)
  *
  * @param array $data
  * @return string
  */
 public function renderTree(array $data)
 {
     $helper = Mage::helper('aoe_profiler');
     /* @var $helper Aoe_Profiler_Helper_Data */
     $output = '';
     foreach ($data as $key => $uniqueId) {
         if (strpos($key, '_children') === false) {
             $tmp = $this->stackLog[$uniqueId];
             $hasChildren = isset($data[$key . '_children']) && count($data[$key . '_children']) > 0;
             $duration = round($tmp['time_total'] * 1000);
             $output .= '<li duration="' . $duration . '" class="' . ($tmp['level'] > 1 ? 'collapsed' : '') . ' level-' . $tmp['level'] . ' ' . ($hasChildren ? 'has-children' : '') . '">';
             $output .= '<div class="info">';
             $output .= '<div class="profiler-label">';
             if ($hasChildren) {
                 $output .= '<div class="toggle profiler-open">&nbsp;</div>';
                 $output .= '<div class="toggle profiler-closed">&nbsp;</div>';
             }
             $label = end($tmp['stack']);
             if (isset($tmp['detail'])) {
                 $label .= ' (' . htmlspecialchars($tmp['detail']) . ')';
             }
             $type = Varien_Profiler::getType($tmp['type'], $label);
             $output .= '<span class="caption type-' . $type . '" title="' . htmlspecialchars($label) . '" />';
             if (isset($tmp['file'])) {
                 $remoteCallUrlTemplate = Mage::getStoreConfig('dev/debug/remoteCallUrlTemplate');
                 $linkTemplate = '<a href="%s" onclick="var ajax = new XMLHttpRequest(); ajax.open(\'GET\', this.href); ajax.send(null); return false">%s</a>';
                 $url = sprintf($remoteCallUrlTemplate, $tmp['file'], intval($tmp['line']));
                 $output .= sprintf($linkTemplate, $url, htmlspecialchars($label));
             } else {
                 $output .= htmlspecialchars($label);
             }
             $output .= '</span>';
             $output .= '</div>';
             // class="label"
             $output .= '<div class="profiler-columns">';
             foreach ($this->metrics as $metric) {
                 $formatterMethod = 'format_' . $metric;
                 $ownTitle = 'Own: ' . $helper->{$formatterMethod}($tmp[$metric . '_own']) . ' ' . $this->units[$metric] . ' / ' . round($tmp[$metric . '_rel_own'] * 100, 2) . '%';
                 $subTitle = 'Sub: ' . $helper->{$formatterMethod}($tmp[$metric . '_sub']) . ' ' . $this->units[$metric] . ' / ' . round($tmp[$metric . '_rel_sub'] * 100, 2) . '%';
                 $totalTitle = $helper->{$formatterMethod}($tmp[$metric . '_own'] + $tmp[$metric . '_sub']) . ' ' . $this->units[$metric] . ' / ' . round(($tmp[$metric . '_rel_own'] + $tmp[$metric . '_rel_sub']) * 100, 2) . '%';
                 $fullTitle = $totalTitle . ' (' . $ownTitle . ', ' . $subTitle . ')';
                 $output .= '<div class="metric" title="' . $fullTitle . '">';
                 $progressBar = $this->renderProgressBar($tmp[$metric . '_rel_own'] * 100, $tmp[$metric . '_rel_sub'] * 100, $tmp[$metric . '_rel_offset'] * 100);
                 $output .= '<div class="' . $metric . ' profiler-column">' . $progressBar . '</div>';
                 $output .= '</div>';
                 // class="metric"
             }
             $output .= '</div>';
             // class="profiler-columns"
             $output .= '</div>';
             // class="info"
             if ($hasChildren) {
                 $output .= '<ul>' . $this->renderTree($data[$key . '_children']) . '</ul>';
             }
             $output .= '</li>';
         }
     }
     return $output;
 }
コード例 #28
0
 public function addMessagesBlockRewrite($eventObject)
 {
     if (Mage::helper('turpentine/esi')->shouldFixFlashMessages()) {
         Varien_Profiler::start('turpentine::observer::esi::addMessagesBlockRewrite');
         Mage::getSingleton('turpentine/shim_mage_core_app')->shim_addClassRewrite('block', 'core', 'messages', 'Fballiano_TurpentineRecentlyViewed_Block_Messages');
         Varien_Profiler::stop('turpentine::observer::esi::addMessagesBlockRewrite');
     }
 }
コード例 #29
0
ファイル: Rule.php プロジェクト: codercv/urbansurprisedev
 /**
  * Update products which are matched for rule
  *
  * @param   Mage_CatalogRule_Model_Rule $rule
  * @return  Mage_CatalogRule_Model_Mysql4_Rule
  */
 public function updateRuleProductData(Mage_CatalogRule_Model_Rule $rule)
 {
     $ruleId = $rule->getId();
     $write = $this->_getWriteAdapter();
     $write->beginTransaction();
     $write->delete($this->getTable('catalogrule/rule_product'), $write->quoteInto('rule_id=?', $ruleId));
     if (!$rule->getIsActive()) {
         $write->commit();
         return $this;
     }
     $websiteIds = explode(',', $rule->getWebsiteIds());
     if (empty($websiteIds)) {
         return $this;
     }
     Varien_Profiler::start('__MATCH_PRODUCTS__');
     $productIds = $rule->getMatchingProductIds();
     Varien_Profiler::stop('__MATCH_PRODUCTS__');
     $customerGroupIds = $rule->getCustomerGroupIds();
     $fromTime = strtotime($rule->getFromDate());
     $toTime = strtotime($rule->getToDate());
     $toTime = $toTime ? $toTime + self::SECONDS_IN_DAY - 1 : 0;
     $sortOrder = (int) $rule->getSortOrder();
     $actionOperator = $rule->getSimpleAction();
     $actionAmount = $rule->getDiscountAmount();
     $actionStop = $rule->getStopRulesProcessing();
     $rows = array();
     $queryStart = 'INSERT INTO ' . $this->getTable('catalogrule/rule_product') . ' (
             rule_id, from_time, to_time, website_id, customer_group_id, product_id, action_operator,
             action_amount, action_stop, sort_order ) values ';
     $queryEnd = ' ON DUPLICATE KEY UPDATE action_operator=VALUES(action_operator),
         action_amount=VALUES(action_amount), action_stop=VALUES(action_stop)';
     try {
         foreach ($productIds as $productId) {
             foreach ($websiteIds as $websiteId) {
                 foreach ($customerGroupIds as $customerGroupId) {
                     $rows[] = "('" . implode("','", array($ruleId, $fromTime, $toTime, $websiteId, $customerGroupId, $productId, $actionOperator, $actionAmount, $actionStop, $sortOrder)) . "')";
                     /**
                      * Array with 1000 rows contain about 2M data
                      */
                     if (sizeof($rows) == 1000) {
                         $sql = $queryStart . join(',', $rows) . $queryEnd;
                         $write->query($sql);
                         $rows = array();
                     }
                 }
             }
         }
         if (!empty($rows)) {
             $sql = $queryStart . join(',', $rows) . $queryEnd;
             $write->query($sql);
         }
         $write->commit();
     } catch (Exception $e) {
         $write->rollback();
         throw $e;
     }
     return $this;
 }
コード例 #30
0
ファイル: Run.php プロジェクト: unifiedarts/Aoe_Profiler
 public function populateMetadata()
 {
     $this->setUrl(Mage::app()->getRequest()->getRequestUri());
     $this->setRoute(Mage::app()->getFrontController()->getAction()->getFullActionName());
     $this->setSessionId(Mage::getSingleton('core/session')->getSessionId());
     $totals = Varien_Profiler::getTotals();
     $this->setTotalTime($totals['time']);
     $this->setTotalMemory((double) $totals['realmem'] / (1024 * 1024));
 }