コード例 #1
0
 /**
  * Processing file data
  *
  * @param string $text
  * @return string
  */
 public function processFileData($text)
 {
     $template = Mage::getModel('core/email_template_filter');
     if (null === $this->_wsdlVariables) {
         $this->_wsdlVariables = new Varien_Object();
         $this->_wsdlVariables->setUrl(Mage::getUrl('*/*/*'));
         $this->_wsdlVariables->setName('Magento');
         $this->_wsdlVariables->setHandler($this->getHandler());
     }
     $template->setVariables(array('wsdl' => $this->_wsdlVariables));
     $text = $template->filter($text);
     return $text;
 }
コード例 #2
0
ファイル: Page.php プロジェクト: hyhoocchan/mage-local
 /**
  * Prepare page object
  *
  * @param array $data
  * @return Varien_Object
  */
 protected function _prepareObject(array $data)
 {
     $object = new Varien_Object();
     $object->setId($data[$this->getIdFieldName()]);
     $object->setUrl($data['url']);
     return $object;
 }
コード例 #3
0
 public function getLastNotice()
 {
     if ($this->showExtendwarePopup === false) {
         return parent::getLastNotice();
     }
     static $lastNotice = false;
     if ($lastNotice === false) {
         $lastNotice = null;
         $message = Mage::helper('ewcore/notification')->getMessage();
         if ($message) {
             $lastNotice = new Varien_Object();
             $lastNotice->setTitle($message->getSubject());
             $lastNotice->setDescription($message->getSummary());
             $lastNotice->setUrl($this->getUrl('extendware_ewcore/adminhtml_message/edit', array('id' => $message->getId())));
             $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR);
             switch ($message->getSeverity()) {
                 case 'notice':
                     $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE);
                     break;
                 case 'minor':
                     $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR);
                     break;
                 case 'major':
                     $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR);
                     break;
                 case 'critical':
                     $lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_CRITICAL);
                     break;
             }
         }
     }
     return $lastNotice;
 }
コード例 #4
0
ファイル: Page.php プロジェクト: vstorm83/ausport
 protected function _prepareObject(array $data)
 {
     $object = new Varien_Object();
     $object->setId($data['post_id']);
     $object->setUrl($data['url']);
     $object->setDate($data['date']);
     return $object;
 }
コード例 #5
0
 /**
  * add a new feed
  *
  * @access public
  * @param string $label
  * @param string $url
  * @param bool $prepare
  * @return Stovpak_Article_Block_Rss
  * @author Ultimate Module Creator
  */
 public function addFeed($label, $url, $prepare = false)
 {
     $link = $prepare ? $this->getUrl($url) : $url;
     $feed = new Varien_Object();
     $feed->setLabel($label);
     $feed->setUrl($link);
     $this->_feeds[$link] = $feed;
     return $this;
 }
コード例 #6
0
ファイル: JsData.php プロジェクト: Emagedev/Yanws
 public function getJson()
 {
     $response = new Varien_Object();
     $helper = Mage::helper('yanws/articleUtils');
     $response->setUrl(Mage::getBaseUrl());
     $response->setConvertTable(Mage::helper('yanws')->_getTransliterator()->getConvertTable());
     $response->setBaseRoute($helper::BASE_ROUTE);
     return $response->toJson();
 }
コード例 #7
0
 /**
  * Add new massaction item
  *
  * $item = array(
  *      'label'    => string,
  *      'complete' => string, // Only for ajax enabled grid (optional)
  *      'url'      => string,
  *      'confirm'  => string, // text of confirmation of this action (optional)
  *      'additional' => string // (optional)
  * );
  *
  * @param string $itemId
  * @param array|Varien_Object $item
  * @return Mage_Backend_Block_Widget_Grid_Massaction_Abstract
  */
 public function addItem($itemId, $item)
 {
     if (is_array($item)) {
         $item = new Varien_Object($item);
     }
     if ($item instanceof Varien_Object) {
         $item->setId($itemId);
         $item->setUrl($this->getUrl($item->getUrl()));
         $this->_items[$itemId] = $item;
     }
     return $this;
 }
コード例 #8
0
ファイル: Soap.php プロジェクト: cewolf2002/magento
 /**
  * Get wsdl config
  *
  * @return Varien_Object
  */
 protected function _getWsdlConfig()
 {
     $wsdlConfig = new Varien_Object();
     $queryParams = $this->getController()->getRequest()->getQuery();
     if (isset($queryParams['wsdl'])) {
         unset($queryParams['wsdl']);
     }
     $wsdlConfig->setUrl(htmlspecialchars(Mage::getUrl('*/*/*', array('_query' => $queryParams))));
     $wsdlConfig->setName('Magento');
     $wsdlConfig->setHandler($this->getHandler());
     return $wsdlConfig;
 }
 protected function _initItems()
 {
     $data = $this->_getItemsData();
     $items = array();
     foreach ($data as $itemData) {
         $obj = new Varien_Object();
         $obj->setData($itemData);
         $obj->setUrl($itemData['value']);
         $items[] = $obj;
     }
     $this->_items = $items;
     return $this;
 }
コード例 #10
0
ファイル: Http.php プロジェクト: hazaeluz/magento_connect
 /**
  * Additionally check for session messages in several domains case
  *
  * @param string $url
  * @param int $code
  * @return Mage_Core_Controller_Response_Http
  */
 public function setRedirect($url, $code = 302)
 {
     /**
      * Use single transport object instance
      */
     if (self::$_transportObject === null) {
         self::$_transportObject = new Varien_Object();
     }
     self::$_transportObject->setUrl($url);
     self::$_transportObject->setCode($code);
     Mage::dispatchEvent('controller_response_redirect', array('response' => $this, 'transport' => self::$_transportObject));
     return parent::setRedirect(self::$_transportObject->getUrl(), self::$_transportObject->getCode());
 }
コード例 #11
0
 protected function _prepareProduct(array $productRow)
 {
     $product = new Varien_Object();
     $product->setId($productRow[$this->getIdFieldName()]);
     $id = $product->getId();
     $productMedia = Mage::getModel('catalog/product')->load($id)->getImage();
     $product->setMedia($productMedia);
     $productName = Mage::getModel('catalog/product')->load($id)->getName();
     $product->setName($productName);
     $productUrl = !empty($productRow['url']) ? $productRow['url'] : 'catalog/product/view/id/' . $product->getId();
     $product->setUrl($productUrl);
     return $product;
 }
コード例 #12
0
ファイル: Page.php プロジェクト: CE-Webmaster/CE-Hub
 public function getCollection($storeId)
 {
     $pages = parent::getCollection($storeId);
     $select = Mage::getModel('amlanding/page')->getCollection()->addFieldToFilter('is_active', 1)->getSelect()->join(array('amlanding_page_store' => $this->getTable('amlanding/page_store')), 'main_table.page_id = amlanding_page_store.page_id', array())->where('amlanding_page_store.store_id IN (?)', array($storeId));
     $query = $this->_getWriteAdapter()->query($select);
     $urlSuffix = Mage::helper('catalog/category')->getCategoryUrlSuffix($storeId);
     $urlSuffix = $urlSuffix ? $urlSuffix : '';
     while ($row = $query->fetch()) {
         $object = new Varien_Object();
         $object->setId($row['page_id']);
         $object->setUrl($row['identifier'] . $urlSuffix);
         $object->setTitle($row['title']);
         $pages[] = $object;
     }
     return $pages;
 }
 protected function _initItems()
 {
     if ('catalogsearch' == Mage::app()->getRequest()->getModuleName()) {
         return parent::_initItems();
     }
     $data = $this->_getItemsData();
     $items = array();
     foreach ($data as $itemData) {
         if (!$itemData) {
             continue;
         }
         $obj = new Varien_Object();
         $obj->setData($itemData);
         $obj->setUrl($itemData['value']);
         $items[] = $obj;
     }
     $this->_items = $items;
     return $this;
 }
コード例 #14
0
ファイル: Http.php プロジェクト: tormit/Ho_Import
 public function download(Varien_Object $connectionInfo, $target)
 {
     $url = $connectionInfo->getUrl();
     if (!$url) {
         Mage::throwException($this->_getLog()->__("No valid URL given: %s", $url));
     }
     $this->_log($this->_getLog()->__("Downloading file %s from %s, to %s", basename($url), $url, $target));
     $targetInfo = pathinfo($target);
     $filename = isset($targetInfo['extension']) ? basename($target) : basename(parse_url($url, PHP_URL_PATH));
     $path = $this->_getTargetPath(dirname($target), $filename);
     $fp = fopen($path, 'w+');
     //This is the file where we save the information
     $cookie = tempnam(Mage::getBaseDir('tmp'), "CURLCOOKIE");
     $ch = curl_init($url);
     //Here is the file we are downloading, replace spaces with %20
     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1");
     curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
     curl_setopt($ch, CURLOPT_ENCODING, "");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_AUTOREFERER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
     curl_setopt($ch, CURLOPT_FILE, $fp);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_exec($ch);
     $response = curl_getinfo($ch);
     curl_close($ch);
     fclose($fp);
     if ($response['http_code'] == 301 || $response['http_code'] == 302) {
         if ($headers = get_headers($response['url'])) {
             foreach ($headers as $value) {
                 if (substr(strtolower($value), 0, 9) == "location:") {
                     $connectionInfo->setUrl(trim(substr($value, 9, strlen($value))));
                     Mage::throwException($this->_getLog()->__("Retrying with forwarded URL: %s", $connectionInfo->getUrl()));
                     return $this->download($connectionInfo, $target);
                 }
             }
         }
     }
     return null;
 }
コード例 #15
0
ファイル: Product.php プロジェクト: rubenjohne/ts-echo
 /**
  * Prepare product
  *
  * @param array $productRow
  * @return Varien_Object
  */
 protected function _prepareProduct(array $productRow)
 {
     $product = new Varien_Object();
     $product->setId($productRow[$this->getIdFieldName()]);
     $productLoaded = Mage::getModel('catalog/product')->setData($productRow);
     $requestPath = $productLoaded->getUrl();
     $idPath = sprintf('product/%d', $productLoaded->getEntityId());
     if (($categoryIdAsc = Mage::helper('ascurl')->getCategoryIdAsc($productLoaded, true)) && Mage::getStoreConfig(self::USE_CANONICAL_URL_AT_GOOGLE_SITEMAP, $productLoaded->getStoreId())) {
         $idPath = sprintf('%s/%d', $idPath, $categoryIdAsc);
     }
     $rewrited = $this->_getWriteAdapter()->query(str_replace('to_replace', $idPath, $this->rewriteQuery))->fetch();
     if (isset($rewrited['request_path'])) {
         $product->setUrl($rewrited['request_path']);
     }
     try {
         if (Mage::getStoreConfig(AW_Ascurl_Model_Sitemap::USE_IMAGES, $productLoaded->getStoreId())) {
             $product->setImageUrl($productLoaded->getImageUrl());
         }
     } catch (Exception $ex) {
     }
     return $product;
 }
コード例 #16
0
ファイル: Category.php プロジェクト: CE-Webmaster/CE-Hub
 protected function _initItems()
 {
     if (!($key = Mage::app()->getRequest()->getParam('am_landing'))) {
         return parent::_initItems();
     }
     $data = $this->_getItemsData();
     $items = array();
     foreach ($data as $itemData) {
         if (!$itemData) {
             continue;
         }
         $obj = new Varien_Object();
         $obj->setData($itemData);
         if (isset($itemData['id'])) {
             /*
              * Navigation works here
              */
             $param = 'cat=' . $itemData['id'];
             $url = Mage::helper('amshopby/url')->getFullUrl();
             $url = preg_replace('/(\\?|&)cat=\\d+/', '$1' . $param, $url, 1, $count);
             if (!$count) {
                 if (strpos($url, '?') !== false) {
                     $url .= '&' . $param;
                 } else {
                     $url .= '?' . $param;
                 }
             }
         } else {
             $url = Mage::helper('amlanding/url')->getLandingUrl(array('cat' => $itemData['value']));
         }
         $obj->setUrl($url);
         $items[] = $obj;
     }
     $this->_items = $items;
     return $this;
 }
コード例 #17
0
ファイル: Item.php プロジェクト: natxetee/magento2
 /**
  * Returns special download params (if needed) for custom option with type = 'file'.
  * Needed to implement Mage_Catalog_Model_Product_Configuration_Item_Interface.
  *
  * We have to customize only controller url, so return it.
  *
  * @return null|Varien_Object
  */
 public function getFileDownloadParams()
 {
     $params = new Varien_Object();
     $params->setUrl($this->_customOptionDownloadUrl);
     return $params;
 }
コード例 #18
0
 /**
  * Prepare category
  *
  * @param array $categoryRow
  * @return Varien_Object
  */
 protected function _prepareCategory(array $categoryRow)
 {
     $category = new Varien_Object();
     $category->setId($categoryRow[$this->getIdFieldName()]);
     $categoryUrl = !empty($categoryRow['url']) ? $categoryRow['url'] : 'catalog/category/view/id/' . $category->getId();
     $category->setUrl($categoryUrl);
     return $category;
 }
コード例 #19
0
 public function saveAction()
 {
     $this->_setTypeId();
     $response = new Varien_Object();
     $response->setError(0);
     $modelSet = Mage::getModel('eav/entity_attribute_set')->setId($this->getRequest()->getParam('id'))->setEntityTypeId(Mage::registry('entityType'));
     if ($this->getRequest()->getParam('gotoEdit')) {
         $modelSet = Mage::getModel('eav/entity_attribute_set');
         $modelSet->setAttributeSetName($this->getRequest()->getParam('attribute_set_name'))->setEntityTypeId(Mage::registry('entityType'));
     } else {
         $data = Zend_Json_Decoder::decode($this->getRequest()->getPost('data'));
         $modelSet->organizeData($data);
     }
     try {
         $modelSet->validate($modelSet->getAttributeSetName());
         $modelSet->save();
         if ($this->getRequest()->getParam('gotoEdit') == 1) {
             $modelSet->initFromSkeleton($this->getRequest()->getParam('skeleton_set'))->save();
             $this->_redirect('*/*/edit', array('id' => $modelSet->getId()));
             $this->_getSession()->addSuccess($this->__('Attribute set successfully saved.'));
         } else {
             $this->_getSession()->addSuccess($this->__('Attribute set successfully saved.'));
             //                $this->_initLayoutMessages('adminhtml/session');
             //                $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
             $response->setUrl($this->getUrl('*/*/edit', array('id' => $modelSet->getId())));
             //$this->_redirect('*/*/'); Why? there is Ajax.
         }
     } catch (Exception $e) {
         $this->_getSession()->addError($e->getMessage());
         if ($this->getRequest()->getParam('gotoEdit') == 1) {
             $this->_redirectReferer();
         } else {
             $this->_initLayoutMessages('adminhtml/session');
             $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
             $response->setError(1);
         }
     }
     if ($this->getRequest()->getParam('gotoEdit') != 1) {
         $this->getResponse()->setBody($response->toJson());
     }
 }
コード例 #20
0
ファイル: Observer.php プロジェクト: mwin007/Magento-Varnish
 /**
  * Called on 
  * 	core_block_abstract_to_html_before
  *
  * Checks if the "esi" variable is set on a block.
  * 	If yes, the template of the block is replaced by varnish/esi.phtml which contains the <esi:include> tag
  * 	it also adds to the response the header X-magento-doesi which will be interpreted by varnish and tell it to do the esi processing
  * 
  * @param array $eventObject
  */
 public function injectEsi($eventObject)
 {
     //No ESI injection if the module is disabled or the request is made on HTTPS
     if (!Mage::helper('varnish')->isVarnishModuleEnabled() || Mage::app()->getRequest()->isSecure()) {
         return;
     }
     $block = $eventObject->getBlock();
     if ($block instanceof Mage_Core_Block_Template) {
         $esi = $block->getEsi();
         if ($esi == true) {
             //We don't allow ESI in admin, for now. Maybe in future releases.
             if (Mage::app()->getStore()->getCode() == 'admin') {
                 throw new Mage_Adminhtml_Exception("ESI includes are forbidden in Admin");
             }
             // We replace the template of the block by the varnish/esi.phtml template
             // The HTML of our template will replace the real HTML of the block
             $block->setTemplate('varnish/esi.phtml');
             $src = new Varien_Object();
             //Blocks change depending on the store id, so we keep track of that
             $src->setStoreId(Mage::app()->getStore()->getId());
             //Blocks also change depending on the design so we keep track of the package and the theme of the current block
             $src->setDesignPackage(Mage::getDesign()->getPackageName());
             $src->setDesignTheme(Mage::getDesign()->getTheme('layout'));
             $src->setNameInLayout($block->getNameInLayout());
             /*
              * Set the cache type
              * 	per-client
              *  per-page
              * 	global
              *
              * 
              * per-client tells varnish to cache the block per-client basis.
              * per-page tells varnish to cache the content based on the url of the page.
              * global tells varnish to serve the same cached version to every client.
              * 
              * The per-client cache is based on the frontend cookie of the client.
              * 
              * We default the cache type to "global"
              */
             if (empty($esi['cache_type'])) {
                 $esi['cache_type'] = 'global';
             }
             $src->setCacheType($esi['cache_type']);
             /**
              *	If the block is cached on a per-page basis
              *	we create an entry in our ESI table to keep track the URLs where the block appear
              *	 
              */
             if ($src->getCacheType() === 'per-page') {
                 $parentUrl = Mage::app()->getRequest()->getRequestString();
                 $src->setParentUrl($parentUrl);
             }
             /**
              * Expiry (or TTL in Varnish lingo). How lon will the object be stored in Varnish?
              * TODO: make sure the expiry is in format 1d 24h 1140m 86400s
              */
             if (!empty($esi['expiry'])) {
                 $src->setExpiry($esi['expiry']);
             } else {
                 if ($src->getCacheType() === 'per-client') {
                     $src->setExpiry(Mage::getStoreConfig('varnish/cache/per_client_default_expiry'));
                 } else {
                     if ($src->getCacheType() === 'per-page') {
                         $src->setExpiry(Mage::getStoreConfig('varnish/cache/per_page_default_expiry'));
                     } else {
                         $src->setExpiry(Mage::getStoreConfig('varnish/cache/global_default_expiry'));
                     }
                 }
             }
             //We create a unique fingerprint with all our values
             foreach ($src->getData() as $value) {
                 $this->_hash($value);
             }
             // $src is the source for our <esi:include> it is composed of all the above variables
             $src->setUrl("/varnish/cache/getBlock/cachetype/{$src->getCacheType()}/expiry/{$src->getExpiry()}/fingerprint/{$this->_hash()}");
             /**
              * Registry save:
              * 	some block rely on values stored in the Mage::registry().
              * 	For example, the product page relies on Mage::registry('current_product');
              *  The problem is that the Mage::registry is not persistent between requests. This means that once the request is served,
              *  the registry looses its data.
              *  This means that when Varnish makes the ESI request, the registry is empty and if the block makes a call to Mage::registry('current_product')
              *  the function will return null.
              *  In order to strive this problem, when you setEsi on a block using the mage registry, you need to specify in the layout which keys you want to keep.
              *  These keys will be saved in the magento cache and thus be accessible when the ESI request is made
              */
             if (!empty($esi['registry_keys'])) {
                 // We create an array with the <registry_keys></registry_keys> set in the layout
                 $registryKeys = explode(',', $esi['registry_keys']);
                 // We iterate through each of the registrykey...
                 foreach ($registryKeys as $registryKey) {
                     $registryContent = Mage::registry($registryKey);
                     if ($registryContent !== null) {
                         // If the key exist we save the content in an array
                         $registry[] = array("key" => $registryKey, "content" => $registryContent);
                     }
                 }
                 $src->setRegistry($registry);
             }
             $src->setBlockType(get_class($block));
             // and we save the content in the cache with the hash as the id
             $cache = Mage::helper('varnish')->getRedisCache();
             $tags = array("VARNISH_CACHETYPE_{$src->getCacheType()}", "VARNISH_BLOCKTYPE_{$src->getBlockType()}", "VARNISH_BLOCKNAME_{$src->getNameInLayout()}");
             $cache->save(serialize($src), $this->_hash(), $tags, null);
             $block->setSrc($src);
             // Tell varnish to do esi processing on the page
             Mage::getSingleton('varnish/cache')->setDoEsi(true);
         }
     }
 }
コード例 #21
0
 /**
  * 
  */
 public function getParts()
 {
     $__AH = Mage::helper('activitystream/adminhtml');
     $__recordTemplate = $__AH->getActivityRecordTemplate($this->getActivity()->getType());
     $__variablesList = $__AH->getActivityTypePossibleVariables($this->getActivity()->getType());
     $__parts = array();
     while (strlen($__recordTemplate) > 0) {
         $__closestVariablePos = null;
         $__closestVariableName = null;
         foreach ($__variablesList as $__variableName) {
             $__variablePos = strpos($__recordTemplate, '{' . $__variableName . '}');
             if ($__variablePos === false) {
                 continue;
             }
             if (is_null($__closestVariablePos) or $__closestVariablePos > $__variablePos) {
                 $__closestVariablePos = $__variablePos;
                 $__closestVariableName = $__variableName;
             }
         }
         if (!is_null($__closestVariablePos)) {
             if ($__closestVariablePos > 0) {
                 $__part = new Varien_Object();
                 $__part->setType(self::PART_TYPE_PLAINTEXT)->setContent(substr($__recordTemplate, 0, $__closestVariablePos));
                 array_push($__parts, $__part);
                 $__recordTemplate = substr($__recordTemplate, $__closestVariablePos);
             }
             $__part = new Varien_Object();
             $__variableName = $__closestVariableName;
             $__value = $this->getActivity()->getData($__AH->getActivityRecordVariableDataKey($__variableName));
             if (!$__value) {
                 $__value = $this->getActivity()->getData(self::DATAKEY_PREFIX_DEFAULT . $__AH->getActivityRecordVariableDataKey($__variableName));
                 if (!$__value) {
                     $__value = $__AH->getActivityRecordVariableDelaultValue($this->getActivity()->getType(), $__variableName);
                     $__part->setIsValueDefault(true);
                 }
             }
             $__part->setType(self::PART_TYPE_VARIABLE)->setName($__variableName)->setValue($__value);
             if (!$__part->getIsValueDefault()) {
                 if ($__variableName == 'Product_title') {
                     $__product = Mage::getModel('catalog/product')->load($this->getActivity()->getProductId());
                     $__product->setStoreId($this->getActivity()->getStoreId());
                     $__part->setUrl(Mage::helper('catalog/product')->getProductUrl($__product));
                     unset($__product);
                 }
                 if ($__variableName == 'Category_title') {
                     $__category = Mage::getModel('catalog/category')->load($this->getActivity()->getCategoryId());
                     $__category->setStoreId($this->getActivity()->getStoreId());
                     $__part->setUrl($this->__getCategoryUrl($__category));
                     unset($__category);
                 }
             }
             array_push($__parts, $__part);
             $__recordTemplate = substr($__recordTemplate, strlen($__closestVariableName) + 2);
         } else {
             $__part = new Varien_Object();
             $__part->setType(self::PART_TYPE_PLAINTEXT)->setContent($__recordTemplate);
             array_push($__parts, $__part);
             $__recordTemplate = '';
         }
     }
     return $__parts;
 }
コード例 #22
0
ファイル: Soap.php プロジェクト: HelioFreitas/magento-pt_br
 /**
  * Run webservice
  *
  * @param Mage_Api_Controller_Action $controller
  * @return Mage_Api_Model_Server_Adapter_Soap
  */
 public function run()
 {
     if ($this->getController()->getRequest()->getParam('wsdl')) {
         // Generating wsdl content from template
         $io = new Varien_Io_File();
         $io->open(array('path' => Mage::getModuleDir('etc', 'Mage_Api')));
         $wsdlContent = $io->read('wsdl.xml');
         $template = Mage::getModel('core/email_template_filter');
         $wsdlConfig = new Varien_Object();
         $wsdlConfig->setUrl(Mage::getUrl('*/*/*'));
         $wsdlConfig->setName('Magento');
         $wsdlConfig->setHandler($this->getHandler());
         $template->setVariables(array('wsdl' => $wsdlConfig));
         $this->getController()->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($template->filter($wsdlContent));
     } elseif ($this->_extensionLoaded()) {
         $this->_soap = new SoapServer(Mage::getUrl('*/*/*', array('wsdl' => 1)));
         use_soap_error_handler(false);
         $this->_soap->setClass($this->getHandler());
         $this->getController()->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($this->_soap->handle());
     } else {
         $this->fault('0', 'Unable to load Soap extension on the server');
     }
     return $this;
 }
コード例 #23
0
 public function writeTempFile($curr_page = 0, $length = 50, $filename = '')
 {
     $products = $this->getFeed()->getProductsCollection('', $curr_page, $length);
     $stock_collection = Mage::getResourceModel('cataloginventory/stock_item_collection');
     $content = file_get_contents($this->getFeed()->getDirPath() . '/feed-' . $this->getFeed()->getId() . '-xml-product-block-template.tmp');
     $fp = fopen($this->getFeed()->getTempFilePath(), 'a');
     $log_fp = fopen(sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), 'log-' . $this->getFeed()->getId() . '.txt'), 'a');
     $log_content = date("F j, Y, g:i:s a") . ', page:' . $curr_page . ', items selected:' . count($products) . "\n";
     fwrite($log_fp, $log_content);
     fclose($log_fp);
     $store = Mage::getModel('core/store')->load($this->getFeed()->getStoreId());
     $root_category = Mage::getModel('catalog/category')->load($store->getRootCategoryId());
     if (Mage::getStoreConfig('gomage_feedpro/imagesettings/enable')) {
         $image_width = intval(Mage::getStoreConfig('gomage_feedpro/imagesettings/width'));
         $image_height = intval(Mage::getStoreConfig('gomage_feedpro/imagesettings/height'));
     } else {
         $image_width = 0;
         $image_height = 0;
     }
     foreach ($products as $_product) {
         $category_path = array();
         $category = null;
         foreach ($_product->getCategoryIds() as $id) {
             $_category = $this->getFeed()->getCategoriesCollection()->getItemById($id);
             if (is_null($category) || $category && $_category && $category->getLevel() < $_category->getLevel()) {
                 $category = $_category;
             }
         }
         if ($category) {
             $category_path = array($category->getName());
             $parent_id = $category->getParentId();
             if ($category->getLevel() > $root_category->getLevel()) {
                 while ($_category = $this->getFeed()->getCategoriesCollection()->getItemById($parent_id)) {
                     if ($_category->getLevel() <= $root_category->getLevel()) {
                         break;
                     }
                     $category_path[] = $_category->getName();
                     $parent_id = $_category->getParentId();
                 }
             }
         }
         $product = new Varien_Object();
         if ($category) {
             $product->setCategory($category->getName());
             $product->setCategoryId($category->getEntityId());
             $product->setCategorySubcategory(implode(' -&gt; ', array_reverse($category_path)));
         } else {
             $product->setCategory('');
             $product->setCategorySubcategory('');
         }
         $template_attributes = $this->getAllVars($content);
         $custom_attributes = Mage::getResourceModel('gomage_feed/custom_attribute_collection');
         $custom_attributes->load();
         foreach ($template_attributes as $attribute_code) {
             $value = null;
             switch ($attribute_code) {
                 case 'parent_sku':
                     if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                         $value = $parent_product->getSku();
                     } else {
                         $value = '';
                     }
                     break;
                 case 'parent_base_image':
                     if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                         $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
                     } else {
                         $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                     }
                     try {
                         if ($image_width || $image_height) {
                             $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                         } else {
                             $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                         }
                     } catch (Exception $e) {
                         $image_url = '';
                     }
                     $value = $image_url;
                     break;
                 case 'price':
                     if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
                         $value = $store->convertPrice($_product->getMinimalPrice(), false, false);
                     } else {
                         $value = $store->convertPrice($_product->getPrice(), false, false);
                     }
                     break;
                 case 'store_price':
                 case 'final_price':
                     $value = $store->convertPrice($_product->getFinalPrice(), false, false);
                     break;
                 case 'image':
                 case 'gallery':
                 case 'media_gallery':
                     $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                     try {
                         if ($image_width || $image_height) {
                             $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                         } else {
                             $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                         }
                     } catch (Exception $e) {
                         $image_url = '';
                     }
                     $product->setData($attribute_code, $image_url);
                     break;
                 case 'image_2':
                 case 'image_3':
                 case 'image_4':
                 case 'image_5':
                     if (!$_product->hasData('media_gallery_images')) {
                         $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                         $_product->setData('media_gallery_images', $_prod->getMediaGalleryImages());
                     }
                     $i = 0;
                     foreach ($_product->getMediaGalleryImages() as $_image) {
                         $i++;
                         if ('image_' . $i == $attribute_code) {
                             if ($image_width || $image_height) {
                                 $product->setData($attribute_code, (string) Mage::helper('catalog/image')->init($_product, 'image', $_image->getFile())->resize($image_width, $image_height));
                             } else {
                                 $product->setData($attribute_code, $_image['url']);
                             }
                         }
                     }
                     break;
                 case 'parent_url':
                     if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                         $product->setParentUrl($parent_product->getProductUrl(false));
                         break;
                     }
                     $product->setParentUrl($_product->getProductUrl(false));
                     break;
                 case 'url':
                     $product->setUrl($_product->getProductUrl(false));
                     break;
                 default:
                     if (strpos($attribute_code, 'custom:') === 0) {
                         $custom_code = trim(str_replace('custom:', '', $attribute_code));
                         if ($custom_attribute = $custom_attributes->getItemByColumnValue('code', $custom_code)) {
                             $options = Zend_Json::decode($custom_attribute->getData('data'));
                             foreach ($options as $option) {
                                 foreach ($option['condition'] as $condition) {
                                     switch ($condition['attribute_code']) {
                                         case 'product_type':
                                             $attr_value = $_product->getTypeId();
                                             break;
                                         case 'price':
                                             if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
                                                 $attr_value = $store->convertPrice($_product->getMinimalPrice(), false, false);
                                             } else {
                                                 $attr_value = $store->convertPrice($_product->getPrice(), false, false);
                                             }
                                             break;
                                         case 'store_price':
                                             $attr_value = $store->convertPrice($_product->getFinalPrice(), false, false);
                                             break;
                                         case 'parent_url':
                                             if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                                                 $attr_value = $parent_product->getProductUrl(false);
                                                 break;
                                             }
                                             $attr_value = $_product->getProductUrl(false);
                                             break;
                                         case 'image':
                                         case 'gallery':
                                         case 'media_gallery':
                                             if (!$_product->hasData('product_base_image')) {
                                                 $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                                                 try {
                                                     if ($image_width || $image_height) {
                                                         $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                                                     } else {
                                                         $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                                                     }
                                                 } catch (Exception $e) {
                                                     $image_url = '';
                                                 }
                                                 $_product->setData('product_base_image', $image_url);
                                                 $attr_value = $image_url;
                                             } else {
                                                 $attr_value = $_product->getData('product_base_image');
                                             }
                                             break;
                                         case 'url':
                                             $attr_value = $_product->getProductUrl(false);
                                             break;
                                         case 'qty':
                                             if ($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())) {
                                                 $attr_value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
                                             } else {
                                                 $attr_value = 0;
                                             }
                                             break;
                                         case 'is_in_stock':
                                             $attr_value = ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getIsInStock());
                                             if (!$attr_value || $attr_value == '' || $attr_value == null) {
                                                 $attr_value = 0;
                                             }
                                             //								            if($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())){
                                             //
                                             //            									$attr_value = $stock_collection->getItemByColumnValue('product_id', $_product->getId())->getData('is_in_stock');
                                             //
                                             //            								}else{
                                             //
                                             //            									$attr_value = 0;
                                             //
                                             //            								}
                                             break;
                                         case 'category':
                                             $attr_value = $product->getCategory();
                                             break;
                                         case 'category_id':
                                             $attr_value = $_product->getCategoryIds();
                                             break;
                                         default:
                                             $attr_value = $_product->getData($condition['attribute_code']);
                                     }
                                     $cond_value = $condition['value'];
                                     $is_multi = false;
                                     if ($product_attribute = $_product->getResource()->getAttribute($condition['attribute_code'])) {
                                         if ($product_attribute->getFrontendInput() == 'multiselect') {
                                             $is_multi = true;
                                             $attr_value = explode(',', $attr_value);
                                         }
                                     }
                                     if ($condition['attribute_code'] == 'category_id') {
                                         $is_multi = true;
                                     }
                                     switch ($condition['condition']) {
                                         case 'eq':
                                             if (!$is_multi && $attr_value == $cond_value || $is_multi && in_array($cond_value, $attr_value)) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'neq':
                                             if (!$is_multi && $attr_value != $cond_value || $is_multi && !in_array($cond_value, $attr_value)) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'gt':
                                             if ($attr_value > $cond_value) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'lt':
                                             if ($attr_value < $cond_value) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'gteq':
                                             if ($attr_value >= $cond_value) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'lteq':
                                             if ($attr_value <= $cond_value) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'like':
                                             if (strpos($attr_value, $cond_value) !== false) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                         case 'nlike':
                                             if (strpos($attr_value, $cond_value) === false) {
                                                 continue 2;
                                             } else {
                                                 continue 3;
                                             }
                                             break;
                                     }
                                 }
                                 if (in_array($option['value_type'], array('percent', 'attribute'))) {
                                     switch ($option['value_type_attribute']) {
                                         case 'price':
                                             if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
                                                 $attribute_value = $store->convertPrice($_product->getMinimalPrice(), false, false);
                                             } else {
                                                 $attribute_value = $store->convertPrice($_product->getPrice(), false, false);
                                             }
                                             break;
                                         case 'store_price':
                                             $attribute_value = $store->convertPrice($_product->getFinalPrice(), false, false);
                                             break;
                                         case 'parent_url':
                                             if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                                                 $attribute_value = $parent_product->getProductUrl(false);
                                                 break;
                                             }
                                             $attribute_value = $_product->getProductUrl(false);
                                             break;
                                         case 'image':
                                         case 'gallery':
                                         case 'media_gallery':
                                             if (!$_product->hasData('product_base_image')) {
                                                 $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                                                 try {
                                                     if ($image_width || $image_height) {
                                                         $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                                                     } else {
                                                         $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                                                     }
                                                 } catch (Exception $e) {
                                                     $image_url = '';
                                                 }
                                                 $_product->setData('product_base_image', $image_url);
                                                 $attribute_value = $image_url;
                                             } else {
                                                 $attribute_value = $_product->getData('product_base_image');
                                             }
                                             break;
                                         case 'url':
                                             $attribute_value = $_product->getProductUrl(false);
                                             break;
                                         case 'qty':
                                             $attribute_value = ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());
                                             if (!$attribute_value || $attribute_value == '' || $attribute_value == null) {
                                                 $attribute_value = 0;
                                             }
                                             //	        								if($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())){
                                             //
                                             //	        									$attribute_value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
                                             //
                                             //	        								}else{
                                             //
                                             //	        									$attribute_value = 0;
                                             //
                                             //	        								}
                                             break;
                                         case 'category':
                                             $attribute_value = $product->getCategory();
                                             break;
                                         default:
                                             $attribute_value = $_product->getData($option['value_type_attribute']);
                                     }
                                 }
                                 if ($option['value_type'] == 'percent') {
                                     $value = floatval($attribute_value) / 100 * floatval($option['value']);
                                 } elseif ($option['value_type'] == 'attribute') {
                                     $value = $attribute_value;
                                 } else {
                                     $value = $option['value'];
                                 }
                                 break;
                             }
                             if ($value === null && $custom_attribute->getDefaultValue()) {
                                 switch ($custom_attribute->getDefaultValue()) {
                                     case 'price':
                                         if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
                                             $value = $store->convertPrice($_product->getMinimalPrice(), false, false);
                                         } else {
                                             $value = $store->convertPrice($_product->getPrice(), false, false);
                                         }
                                         break;
                                     case 'store_price':
                                         $value = $store->convertPrice($_product->getFinalPrice(), false, false);
                                         break;
                                     case 'parent_url':
                                         if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
                                             $value = $parent_product->getProductUrl(false);
                                             break;
                                         }
                                         $value = $_product->getProductUrl(false);
                                         break;
                                     case 'image':
                                     case 'gallery':
                                     case 'media_gallery':
                                         if (!$_product->hasData('product_base_image')) {
                                             $_prod = Mage::getModel('catalog/product')->load($_product->getId());
                                             try {
                                                 if ($image_width || $image_height) {
                                                     $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
                                                 } else {
                                                     $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
                                                 }
                                             } catch (Exception $e) {
                                                 $image_url = '';
                                             }
                                             $_product->setData('product_base_image', $image_url);
                                             $value = $image_url;
                                         } else {
                                             $value = $_product->getData('product_base_image');
                                         }
                                         break;
                                     case 'url':
                                         $value = $_product->getProductUrl(false);
                                         break;
                                     case 'qty':
                                         $value = ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());
                                         if (!$value || $value == '' || $value == null) {
                                             $value = 0;
                                         }
                                         //        								if($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())){
                                         //
                                         //        									$value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
                                         //
                                         //        								}else{
                                         //
                                         //        									$value = 0;
                                         //
                                         //        								}
                                         break;
                                     case 'category':
                                         $value = $product->getCategory();
                                         break;
                                     default:
                                         $value = $_product->getData($custom_attribute->getDefaultValue());
                                 }
                             }
                         }
                     } elseif ($attribute_model = $_product->getResource()->getAttribute($attribute_code)) {
                         switch ($attribute_model->getFrontendInput()) {
                             case 'select':
                             case 'multiselect':
                                 $value = implode(', ', (array) $_product->getAttributeText($attribute_code));
                                 break;
                             default:
                                 $value = $_product->getData($attribute_code);
                                 break;
                         }
                     }
                     break;
             }
             if ($value && !$product->getData($attribute_code)) {
                 $product->setData($attribute_code, $value);
             }
         }
         $product->setDescription(strip_tags(preg_replace('/<br.*?>/s', "\r\n", $_product->getDescription())));
         $product->setShortDescription(strip_tags(preg_replace('/<br.*?>/s', "\r\n", $_product->getShortDescription())));
         $product->setQty(ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()));
         fwrite($fp, parent::setVars($content, $product) . "\r\n");
     }
     fclose($fp);
 }
コード例 #24
0
ファイル: Soap.php プロジェクト: hirentricore/devmagento
 /**
  * Run webservice
  *
  * @param Mage_Api_Controller_Action $controller
  * @return Mage_Api_Model_Server_Adapter_Soap
  */
 public function run()
 {
     $apiConfigCharset = Mage::getStoreConfig("api/config/charset");
     if ($this->getController()->getRequest()->getParam('wsdl') !== null) {
         // Generating wsdl content from template
         $io = new Varien_Io_File();
         $io->open(array('path' => Mage::getModuleDir('etc', 'Mage_Api')));
         $wsdlContent = $io->read('wsdl.xml');
         $template = Mage::getModel('core/email_template_filter');
         $wsdlConfig = new Varien_Object();
         $queryParams = $this->getController()->getRequest()->getQuery();
         if (isset($queryParams['wsdl'])) {
             unset($queryParams['wsdl']);
         }
         $wsdlConfig->setUrl(htmlspecialchars(Mage::getUrl('*/*/*', array('_query' => $queryParams))));
         $wsdlConfig->setName('Magento');
         $wsdlConfig->setHandler($this->getHandler());
         $template->setVariables(array('wsdl' => $wsdlConfig));
         $this->getController()->getResponse()->clearHeaders()->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)->setBody(preg_replace('/<\\?xml version="([^\\"]+)"([^\\>]+)>/i', '<?xml version="$1" encoding="' . $apiConfigCharset . '"?>', $template->filter($wsdlContent)));
     } else {
         try {
             $this->_instantiateServer();
             $this->getController()->getResponse()->clearHeaders()->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)->setBody(preg_replace('/<\\?xml version="([^\\"]+)"([^\\>]+)>/i', '<?xml version="$1" encoding="' . $apiConfigCharset . '"?>', $this->_soap->handle()));
         } catch (Zend_Soap_Server_Exception $e) {
             $this->fault($e->getCode(), $e->getMessage());
         } catch (Exception $e) {
             $this->fault($e->getCode(), $e->getMessage());
         }
     }
     return $this;
 }
コード例 #25
0
 /**
  * Prepare product
  *
  * @param array $productRow
  * @return Varien_Object
  */
 protected function _prepareProduct(array $productRow)
 {
     $product = new Varien_Object();
     $product->setId($productRow[$this->getIdFieldName()]);
     $productUrl = !empty($productRow['url']) ? $productRow['url'] : 'catalog/product/view/id/' . $product->getId();
     $product->setUrl($productUrl);
     return $product;
 }
コード例 #26
0
 /**
  * Prepare product
  *
  * @param array $productRow
  * @return Varien_Object
  */
 protected function _prepareProduct(array $productRow)
 {
     $attribute = Mage::getSingleton('catalog/product')->getResource()->getAttribute('media_gallery');
     $media = Mage::getResourceSingleton('catalog/product_attribute_backend_media');
     $product = new Varien_Object();
     $product->setId($productRow[$this->getIdFieldName()]);
     $productUrl = !empty($productRow['url']) ? $productRow['url'] : 'catalog/product/view/id/' . $product->getId();
     $product->setUrl($productUrl);
     if (isset($productRow['canonical_cross_domain'])) {
         $product->setCanonicalCrossDomain($productRow['canonical_cross_domain']);
     }
     $gallery = $media->loadGallery($product, new Varien_Object(array('attribute' => $attribute)));
     if (count($gallery)) {
         $product->setGallery($gallery);
     }
     return $product;
 }
コード例 #27
0
 /**
  * Prepare catalog object
  *
  * @param array $row
  * @return Varien_Object
  */
 protected function _prepareObject(array $row)
 {
     $entity = new Varien_Object();
     $entity->setId($row[$this->getIdFieldName()]);
     $entity->setUrl($this->_getEntityUrl($row, $entity));
     return $entity;
 }
コード例 #28
0
ファイル: Dpd.php プロジェクト: GabrielCC/zitec-dpd-master
 /**
  *
  * @param string                                            $trackingNumber
  * @param string                                            $carrierTitle
  * @param string                                            $errorMessage
  * @param Zitec_Dpd_Api_Shipment_GetShipmentStatus_Response $response
  *
  * @return \Varien_Object
  */
 protected function _getTrackingInfoObject($trackingNumber, $carrierTitle, $errorMessage, Zitec_Dpd_Api_Shipment_GetShipmentStatus_Response $response = null)
 {
     $result = $result = new Varien_Object();
     $result->setTracking($trackingNumber);
     $result->setCarrierTitle($carrierTitle);
     $result->setErrorMessage($errorMessage);
     if ($response) {
         $result->setUrl($response->getTrackingUrl());
         $result->setDeliverydate($response->getDeliveryDate());
         $result->setDeliverytime($response->getDeliveryTime());
         $result->setShippedDate($response->getShipDate());
         $result->setService($response->getServiceDescription());
         $result->setWeight($response->getWeight());
     }
     return $result;
 }