当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Catalog_Model_Product::getRequestPath方法代码示例

本文整理汇总了PHP中Mage_Catalog_Model_Product::getRequestPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getRequestPath方法的具体用法?PHP Mage_Catalog_Model_Product::getRequestPath怎么用?PHP Mage_Catalog_Model_Product::getRequestPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Catalog_Model_Product的用法示例。


在下文中一共展示了Mage_Catalog_Model_Product::getRequestPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getProductUrl

 /**
  * @param Mage_Catalog_Model_Product $product
  *
  * @return string
  */
 public function getProductUrl(Mage_Catalog_Model_Product $product)
 {
     $productPath = $product->getRequestPath();
     if ($this->isSeoUrlExists()) {
         $url = Mage::helper('amseourl/product_url_rewrite')->getProductPath($product);
         if ($url) {
             $productPath = $url;
         }
     } elseif ($product->getUrlPath()) {
         $productPath = $product->getUrlPath();
     }
     return rtrim(Mage::getUrl('', array('_direct' => $productPath)), '/');
 }
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:18,代码来源:Data.php

示例2: getUrl

 /**
  * Retrieve Product URL using UrlDataObject
  *
  * @param Mage_Catalog_Model_Product $product
  * @param array $params
  * @return string
  */
 public function getUrl(Mage_Catalog_Model_Product $product, $params = array())
 {
     $routePath = '';
     $routeParams = $params;
     $storeId = $product->getStoreId();
     if (isset($params['_ignore_category'])) {
         unset($params['_ignore_category']);
         $categoryId = null;
     } else {
         $categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId() ? $product->getCategoryId() : null;
     }
     if ($product->hasUrlDataObject()) {
         $requestPath = $product->getUrlDataObject()->getUrlRewrite();
         $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
     } else {
         $requestPath = $product->getRequestPath();
         if (empty($requestPath) && $requestPath !== false) {
             $idPath = sprintf('product/%d', $product->getEntityId());
             if ($categoryId) {
                 $idPath = sprintf('%s/%d', $idPath, $categoryId);
             }
             $rewrite = $this->getUrlRewrite();
             $rewrite->setStoreId($storeId)->loadByIdPath($idPath);
             if ($rewrite->getId()) {
                 $requestPath = $rewrite->getRequestPath();
                 $product->setRequestPath($requestPath);
             } else {
                 $product->setRequestPath(false);
             }
         }
     }
     if (isset($routeParams['_store'])) {
         $storeId = Mage::app()->getStore($routeParams['_store'])->getId();
     }
     if ($storeId != Mage::app()->getStore()->getId()) {
         $routeParams['_store_to_url'] = true;
     }
     if (!empty($requestPath)) {
         $routeParams['_direct'] = $requestPath;
     } else {
         $routePath = 'catalog/product/view';
         $routeParams['id'] = $product->getId();
         $routeParams['s'] = $product->getUrlKey();
         if ($categoryId) {
             $routeParams['category'] = $categoryId;
         }
     }
     // reset cached URL instance GET query params
     if (!isset($routeParams['_query'])) {
         $routeParams['_query'] = array();
     }
     return $this->getUrlInstance()->setStore($storeId)->getUrl($routePath, $routeParams);
 }
开发者ID:natxetee,项目名称:magento2,代码行数:60,代码来源:Url.php

示例3: _getProductRequestPath

 /**
  * Get product request path
  *
  * @param Mage_Catalog_Model_Product $product
  * @return string
  * @deprecated since 1.13.0.2
  */
 protected function _getProductRequestPath(Mage_Catalog_Model_Product $product)
 {
     /**
      * Initialize request_path value
      */
     $product->getProductUrl();
     /** @var $helper Enterprise_Catalog_Helper_Data */
     $helper = $this->_factory->getHelper('enterprise_catalog');
     return $helper->getProductRequestPath($product->getRequestPath(), $product->getStoreId());
 }
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:17,代码来源:Observer.php

示例4: getUrl

 /**
  * Retrieve Product URL using UrlDataObject
  *
  * @param Mage_Catalog_Model_Product $product
  * @param array $params
  * @return string
  */
 public function getUrl(Mage_Catalog_Model_Product $product, $params = array())
 {
     $url = $product->getData('url');
     if (!empty($url)) {
         return $url;
     }
     $requestPath = $product->getRequestPath();
     if (empty($requestPath)) {
         $requestPath = $this->_getRequestPath($product, $this->_getCategoryIdForUrl($product, $params));
         $product->setRequestPath($requestPath);
     }
     if (isset($params['_store'])) {
         $storeId = $this->_getStoreId($params['_store']);
     } else {
         $storeId = $product->getStoreId();
     }
     if ($storeId != $this->_getStoreId()) {
         $params['_store_to_url'] = true;
     }
     // reset cached URL instance GET query params
     if (!isset($params['_query'])) {
         $params['_query'] = array();
     }
     $this->getUrlInstance()->setStore($storeId);
     $productUrl = $this->_getProductUrl($product, $requestPath, $params);
     $product->setData('url', $productUrl);
     return $product->getData('url');
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:35,代码来源:Url.php

示例5: _addItemXml

 protected function _addItemXml($xml, Mage_Catalog_Model_Product $product, $selectedCategory)
 {
     $item = $xml->addChild("item");
     $name = $this->_nameFormat;
     foreach ($this->_nameAttributes as $attr) {
         $attrData = $product->getData($attr);
         if (isset($this->_attributeOptions[$attr]) && isset($this->_attributeOptions[$attr][$attrData])) {
             $attrData = $this->_attributeOptions[$attr][$attrData];
         }
         $name = str_replace($this->_attributeSymbol . $attr, $attrData, $name);
     }
     $item->name = $name;
     // Generating full URL for a product
     $categorySuffix = Mage::getStoreConfig("catalog/seo/category_url_suffix");
     if ($categorySuffix && strstr($selectedCategory['url'], $categorySuffix)) {
         $item->link = str_replace($categorySuffix, "/" . $product->getRequestPath(), $selectedCategory['url']);
     } else {
         $item->link = $selectedCategory['url'] . "/" . $product->getRequestPath();
     }
     /** @var $taxHelper Mage_Tax_Helper_Data */
     $taxHelper = Mage::helper('tax');
     $priceIncludingTax = $taxHelper->getPrice($product, $product->getFinalPrice(1), true);
     $item->price = $priceIncludingTax;
     //$item->price = number_format((float)$product->getFinalPrice(1), 2);
     $imageUrl = Mage::getUrl('feedsalidzini/info/image/', array('product' => $product->getId()));
     $item->image = $_SERVER["SCRIPT_FILENAME"] ? str_replace($_SERVER["SCRIPT_FILENAME"] . "/", "", $imageUrl) : $imageUrl;
     $categoryName = $selectedCategory['name'];
     $parentId = $selectedCategory['parent'];
     while ($parentId) {
         if ($this->_tmpCategories[$parentId]['level'] > 1) {
             $categoryName = $this->_tmpCategories[$parentId]['name'] . " >> " . $categoryName;
             $parentId = $this->_tmpCategories[$parentId]['parent'];
         } else {
             break;
         }
     }
     $item->category_full = $categoryName;
     $item->category_link = $selectedCategory['url'];
     $item->manufacturer = $this->_attributeOptions['manufacturer'][$product->getManufacturer()];
     if ($product->getModel()) {
         $item->model = $product->getModel();
     }
     if ($this->_includeStock && (!$this->_isComplexProduct($product) || $this->_emulateStock)) {
         $item->in_stock = $this->_getStock($product, $this->_stock[$product->getId()]);
     }
     if ($this->_includeDeliveryCost) {
         $item->delivery_cost_riga = $this->_getDeliveryCost($product);
     }
     return $xml;
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:50,代码来源:Feedsalidzini.php

示例6: getProductUrl

 /**
  * Get product url
  *
  * @param  Mage_Catalog_Model_Product $product
  * @param  bool $useSid
  * @return string
  */
 public function getProductUrl($product, $useSid = null)
 {
     if ($useSid === null) {
         $useSid = Mage::app()->getUseSessionInUrl();
     }
     $categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId() ? $product->getCategoryId() : 0;
     $cacheUrlKey = sprintf('url_%d_%d', $categoryId, $useSid);
     $url = $product->getData($cacheUrlKey);
     if (is_null($url)) {
         if ($product->getStoreId()) {
             $this->getUrlInstance()->setStore($product->getStoreId());
         }
         // auto add SID to URL
         $originalSid = $this->getUrlInstance()->getUseSession();
         if ($originalSid != $useSid) {
             $this->getUrlInstance()->setUseSession($useSid);
         }
         if ($product->hasData('request_path') && $product->getRequestPath() != '') {
             $this->setData($cacheUrlKey, $this->getUrlInstance()->getDirectUrl($product->getRequestPath()));
             $this->getUrlInstance()->setUseSession($originalSid);
             return $this->getData($cacheUrlKey);
         }
         Varien_Profiler::start('REWRITE: ' . __METHOD__);
         $rewrite = $this->getUrlRewrite();
         if ($product->getStoreId()) {
             $rewrite->setStoreId($product->getStoreId());
         } else {
             $rewrite->setStoreId(Mage::app()->getStore()->getId());
         }
         $idPath = 'product/' . $product->getId();
         if ($product->getCategoryId() && !$product->getDoNotUseCategoryId() && Mage::getStoreConfig('catalog/seo/product_use_categories')) {
             $idPath .= '/' . $product->getCategoryId();
         }
         $rewrite->loadByIdPath($idPath);
         //echo $this->getUrlInstance()->getBaseUrl();
         if ($rewrite->getId()) {
             $this->setData($cacheUrlKey, $this->getUrlInstance()->getDirectUrl($rewrite->getRequestPath()));
             Varien_Profiler::stop('REWRITE: ' . __METHOD__);
             $this->getUrlInstance()->setUseSession($originalSid);
             return $this->getData($cacheUrlKey);
         }
         Varien_Profiler::stop('REWRITE: ' . __METHOD__);
         Varien_Profiler::start('REGULAR: ' . __METHOD__);
         $url = $this->getUrlInstance()->getUrl('catalog/product/view', array('id' => $product->getId(), 's' => $product->getUrlKey(), 'category' => $product->getCategoryId()));
         $this->getUrlInstance()->setUseSession($originalSid);
         Varien_Profiler::stop('REGULAR: ' . __METHOD__);
     }
     return $url;
 }
开发者ID:jauderho,项目名称:magento-mirror,代码行数:56,代码来源:Url.php

示例7: getObject

 public function getObject(Mage_Catalog_Model_Product $product)
 {
     $type = $this->config->getMappedProductType($product->getTypeId());
     $this->logger->start('CREATE RECORD ' . $product->getId() . ' ' . $this->logger->getStoreName($product->storeId));
     $this->logger->log('Product type (' . $product->getTypeId() . ', mapped to: ' . $type . ')');
     $defaultData = array();
     $transport = new Varien_Object($defaultData);
     Mage::dispatchEvent('algolia_product_index_before', array('product' => $product, 'custom_data' => $transport));
     $defaultData = $transport->getData();
     $defaultData = is_array($defaultData) ? $defaultData : explode("|", $defaultData);
     $visibility = (int) $product->getVisibility();
     $visibleInCatalog = Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds();
     $visibleInSearch = Mage::getSingleton('catalog/product_visibility')->getVisibleInSearchIds();
     $customData = array('objectID' => $product->getId(), 'name' => $product->getName(), 'url' => Mage::getBaseUrl() . $product->getRequestPath(), 'visibility_search' => (int) in_array($visibility, $visibleInSearch), 'visibility_catalog' => (int) in_array($visibility, $visibleInCatalog));
     $additionalAttributes = $this->config->getProductAdditionalAttributes($product->getStoreId());
     $groups = null;
     if ($this->isAttributeEnabled($additionalAttributes, 'description')) {
         $customData['description'] = $product->getDescription();
     }
     $categories = array();
     $categories_with_path = array();
     $_categoryIds = $product->getCategoryIds();
     if (is_array($_categoryIds) && count($_categoryIds) > 0) {
         $categoryCollection = Mage::getResourceModel('catalog/category_collection')->addAttributeToSelect('name')->addAttributeToFilter('entity_id', $_categoryIds)->addFieldToFilter('level', array('gt' => 1))->addIsActiveFilter();
         $rootCat = Mage::app()->getStore($product->getStoreId())->getRootCategoryId();
         foreach ($categoryCollection as $category) {
             // Check and skip all categories that is not
             // in the path of the current store.
             $path = $category->getPath();
             $path_parts = explode("/", $path);
             if (isset($path_parts[1]) && $path_parts[1] != $rootCat) {
                 continue;
             }
             $categoryName = $category->getName();
             if ($categoryName) {
                 $categories[] = $categoryName;
             }
             $category->getUrlInstance()->setStore($product->getStoreId());
             $path = array();
             foreach ($category->getPathIds() as $treeCategoryId) {
                 $name = $this->getCategoryName($treeCategoryId, $product->getStoreId());
                 if ($name) {
                     $path[] = $name;
                 }
             }
             $categories_with_path[] = $path;
         }
     }
     foreach ($categories_with_path as $result) {
         for ($i = count($result) - 1; $i > 0; $i--) {
             $categories_with_path[] = array_slice($result, 0, $i);
         }
     }
     $categories_with_path = array_intersect_key($categories_with_path, array_unique(array_map('serialize', $categories_with_path)));
     $categories_hierarchical = array();
     $level_name = 'level';
     foreach ($categories_with_path as $category) {
         for ($i = 0; $i < count($category); $i++) {
             if (isset($categories_hierarchical[$level_name . $i]) === false) {
                 $categories_hierarchical[$level_name . $i] = array();
             }
             $categories_hierarchical[$level_name . $i][] = implode(' /// ', array_slice($category, 0, $i + 1));
         }
     }
     foreach ($categories_hierarchical as &$level) {
         $level = array_values(array_unique($level));
     }
     foreach ($categories_with_path as &$category) {
         $category = implode(' /// ', $category);
     }
     $customData['categories'] = $categories_hierarchical;
     $customData['categories_without_path'] = $categories;
     if (false === isset($defaultData['thumbnail_url'])) {
         $thumb = Mage::helper('algoliasearch/image')->init($product, 'thumbnail')->resize(75, 75);
         try {
             $customData['thumbnail_url'] = $thumb->toString();
             $customData['thumbnail_url'] = str_replace(array('https://', 'http://'), '//', $customData['thumbnail_url']);
         } catch (\Exception $e) {
             $this->logger->log($e->getMessage());
             $this->logger->log($e->getTraceAsString());
             $customData['thumbnail_url'] = str_replace(array('https://', 'http://'), '//', Mage::getDesign()->getSkinUrl($thumb->getPlaceholder()));
         }
     }
     if (false === isset($defaultData['image_url'])) {
         $image = Mage::helper('algoliasearch/image')->init($product, $this->config->getImageType())->resize($this->config->getImageWidth(), $this->config->getImageHeight());
         try {
             $customData['image_url'] = $image->toString();
             $customData['image_url'] = str_replace(array('https://', 'http://'), '//', $customData['image_url']);
         } catch (\Exception $e) {
             $this->logger->log($e->getMessage());
             $this->logger->log($e->getTraceAsString());
             $customData['image_url'] = str_replace(array('https://', 'http://'), '//', Mage::getDesign()->getSkinUrl($image->getPlaceholder()));
         }
         if ($this->isAttributeEnabled($additionalAttributes, 'media_gallery')) {
             $product->load('media_gallery');
             $customData['media_gallery'] = array();
             foreach ($product->getMediaGalleryImages() as $image) {
                 $customData['media_gallery'][] = str_replace(array('https://', 'http://'), '//', $image->getUrl());
             }
         }
//.........这里部分代码省略.........
开发者ID:IvanRybakov,项目名称:algoliasearch-magento,代码行数:101,代码来源:Producthelper.php


注:本文中的Mage_Catalog_Model_Product::getRequestPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。