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


PHP Mage_Catalog_Model_Product::getProductUrl方法代码示例

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


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

示例1: open

 public function open($product_id)
 {
     $this->_product = Mage::getModel('catalog/product')->load($product_id);
     if ($this->_product->getId()) {
         $this->url($this->_product->getProductUrl());
         return $this;
     }
     throw new Exception("product not found");
 }
开发者ID:nhp,项目名称:Xtest,代码行数:9,代码来源:Product.php

示例2: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Google_Service_ShoppingContent_Product $shoppingProduct
  * @return Google_Service_ShoppingContent_Product
  */
 public function convertAttribute($product, $shoppingProduct)
 {
     $url = $product->getProductUrl(false);
     if ($url) {
         $config = Mage::getSingleton('googleshoppingapi/config');
         if (!Mage::getStoreConfigFlag('web/url/use_store') && $config->getAddStoreCodeToUrl()) {
             Mage::log($config->getAddStoreCodeToUrl() ? "true" : "false");
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         if ($config->getAddUtmSrcGshopping($product->getStoreId())) {
             $url .= '&utm_source=GoogleShopping';
         }
         if ($customUrlParameters = $config->getCustomUrlParameters($product->getStoreId())) {
             $url .= $customUrlParameters;
         }
         $shoppingProduct->setLink($url);
     }
     return $shoppingProduct;
 }
开发者ID:rithala,项目名称:GoogleMagento,代码行数:32,代码来源:Link.php

示例3: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Varien_Gdata_Gshopping_Entry $entry
  * @return Varien_Gdata_Gshopping_Entry
  */
 public function convertAttribute($product, $entry)
 {
     $url = $product->getProductUrl(false);
     if ($url) {
         if (!Mage::getStoreConfigFlag('web/url/use_store')) {
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         $links = $entry->getLink();
         if (!is_array($links)) {
             $links = array();
         }
         $link = $entry->getService()->newLink();
         $link->setHref($url);
         $link->setRel('alternate');
         $link->setType('text/html');
         if ($product->getName()) {
             $link->setTitle($product->getName());
         }
         $links[0] = $link;
         $entry->setLink($links);
     }
     return $entry;
 }
开发者ID:ksaltik,项目名称:tooldexlive,代码行数:36,代码来源:Link.php

示例4: getItemBaseInfo

 public function getItemBaseInfo()
 {
     $helper = Mage::helper('catalog/image');
     $helper->init($this->product, $this->getProductImageType())->keepAspectRatio($this->_keepAspectRatio)->keepFrame($this->_keepFrame);
     $this->item['item_id'] = $this->product->getId();
     $this->item['item_title'] = $this->product->getName();
     $this->item['item_url'] = $this->product->getProductUrl();
     $this->item['cid'] = $this->product->getCategoryIds();
     $this->item['qty'] = $this->product->getStockItem()->getQty();
     $this->item['thumbnail_pic_url'] = (string) $helper->resize($this->thumbnail_with, $this->thumbnail_height);
     $this->item['main_pic_url'] = (string) $helper->resize($this->main_with, $this->main_height);
     $this->item['is_virtual'] = $this->product->isVirtual();
     $this->item['item_status'] = $this->product->isSaleable() ? 'instock' : 'outofstock';
     if (!$this->product->getRatingSummary()) {
         Mage::getModel('review/review')->getEntitySummary($this->product, Mage::app()->getStore()->getId());
     }
     $this->item['allow_add_to_cart'] = !$this->HasOptions();
     $this->item['rating_score'] = round((int) $this->product->getRatingSummary()->getRatingSummary() / 20);
     $this->item['rating_count'] = $this->product->getRatingSummary()->getReviewsCount();
     $this->item['sales_type'] = $this->product->isInStock() ? 'stock' : 'distribute';
     $this->item['qty_min_unit'] = 1;
     $stockItem = $this->product->getStockItem();
     if ($stockItem) {
         if ($stockItem->getMinSaleQty() && $stockItem->getMinSaleQty() > 0) {
             $this->item['qty_min_unit'] = $stockItem->getMinSaleQty();
         }
     }
     $this->item['item_type'] = $this->product->getTypeId();
     return $this->item;
 }
开发者ID:guohuadeng,项目名称:stampApp,代码行数:30,代码来源:ItemController.php

示例5: redirectToProductPage

 /**
  * Redirect to product page
  *
  * @param \Mage_Catalog_Model_Product $product
  */
 public function redirectToProductPage(Mage_Catalog_Model_Product $product)
 {
     $response = Mage::app()->getResponse();
     $response->setRedirect($product->getProductUrl());
     $response->sendResponse();
     exit;
 }
开发者ID:KaiStapel,项目名称:Magento-FACTFinder,代码行数:12,代码来源:Data.php

示例6: productToXmlObject

 /**
  * Retrieve product attributes as xml object
  *
  * @param Mage_Catalog_Model_Product $product
  * @param string $itemNodeName
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function productToXmlObject(Mage_Catalog_Model_Product $product, $itemNodeName = 'item')
 {
     /** @var $item Mage_XmlConnect_Model_Simplexml_Element */
     $item = Mage::getModel('xmlconnect/simplexml_element', '<' . $itemNodeName . '></' . $itemNodeName . '>');
     if ($product && $product->getId()) {
         $item->addChild('entity_id', $product->getId());
         $item->addChild('name', $item->escapeXml($product->getName()));
         $item->addChild('entity_type', $product->getTypeId());
         $item->addChild('short_description', $item->escapeXml($product->getShortDescription()));
         $description = Mage::helper('xmlconnect')->htmlize($item->xmlentities($product->getDescription()));
         $item->addChild('description', $description);
         $item->addChild('link', $product->getProductUrl());
         if ($itemNodeName == 'item') {
             $imageToResize = Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small');
             $propertyToResizeName = 'small_image';
         } else {
             $imageToResize = Mage::helper('xmlconnect/image')->getImageSizeForContent('product_big');
             $propertyToResizeName = 'image';
         }
         $icon = clone Mage::helper('catalog/image')->init($product, $propertyToResizeName)->resize($imageToResize);
         $iconXml = $item->addChild('icon', $icon);
         $file = Mage::helper('xmlconnect')->urlToPath($icon);
         $iconXml->addAttribute('modification_time', filemtime($file));
         $item->addChild('in_stock', (int) $product->getIsInStock());
         $item->addChild('is_salable', (int) $product->isSalable());
         /**
          * By default all products has gallery (because of collection not load gallery attribute)
          */
         $hasGallery = 1;
         if ($product->getMediaGalleryImages()) {
             $hasGallery = sizeof($product->getMediaGalleryImages()) > 0 ? 1 : 0;
         }
         $item->addChild('has_gallery', $hasGallery);
         /**
          * If product type is grouped than it has options as its grouped items
          */
         if ($product->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE || $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
             $product->setHasOptions(true);
         }
         $item->addChild('has_options', (int) $product->getHasOptions());
         if ($minSaleQty = $this->_getMinimalQty($product)) {
             $item->addChild('min_sale_qty', (int) $minSaleQty);
         }
         if (!$product->getRatingSummary()) {
             Mage::getModel('review/review')->getEntitySummary($product, Mage::app()->getStore()->getId());
         }
         $item->addChild('rating_summary', round((int) $product->getRatingSummary()->getRatingSummary() / 10));
         $item->addChild('reviews_count', $product->getRatingSummary()->getReviewsCount());
         if ($this->getChild('product_price')) {
             $this->getChild('product_price')->setProduct($product)->setProductXmlObj($item)->collectProductPrices();
         }
         if ($this->getChild('additional_info')) {
             $this->getChild('additional_info')->addAdditionalData($product, $item);
         }
     }
     return $item;
 }
开发者ID:rajanlamic,项目名称:OpenArtist,代码行数:64,代码来源:Product.php

示例7: getProductUrl

 public function getProductUrl($useSid = null)
 {
     if (is_callable(array($this->getTypeInstance(), 'hasConfigurableProductParentId')) && $this->getTypeInstance()->hasConfigurableProductParentId()) {
         $confProdId = $this->getTypeInstance()->getConfigurableProductParentId();
         return Mage::getModel('catalog/product')->load($confProdId)->getProductUrl();
     } else {
         return parent::getProductUrl($useSid);
     }
 }
开发者ID:Emulator000,项目名称:magento-configurable-simple,代码行数:9,代码来源:Product.php

示例8: testGetProductUrl

 /**
  * @covers Mage_Catalog_Model_Product::getProductUrl
  * @covers Mage_Catalog_Model_Product::getUrlInStore
  */
 public function testGetProductUrl()
 {
     $this->assertStringEndsWith('catalog/product/view/', $this->_model->getProductUrl());
     $this->assertStringEndsWith('catalog/product/view/', $this->_model->getUrlInStore());
     $this->_model->setId(999);
     $url = $this->_model->getProductUrl();
     $this->assertContains('catalog/product/view', $url);
     $this->assertContains('id/999', $url);
     $storeUrl = $this->_model->getUrlInStore();
     $this->assertEquals($storeUrl, $url);
 }
开发者ID:relue,项目名称:magento2,代码行数:15,代码来源:ProductExternalTest.php

示例9: getFullProductUrl

 /**
  * get the longest url for a product
  * from http://magento.stackexchange.com/questions/52969/get-product-path-from-id-with-category-path-in-url
  * @param  Mage_Catalog_Model_Product|null $product [description]
  * @return String full url of the product
  */
 public static function getFullProductUrl(Mage_Catalog_Model_Product $product = null)
 {
     // Force display deepest child category as request path.
     $categories = $product->getCategoryCollection();
     $deepCatId = 0;
     $path = '';
     $productPath = false;
     foreach ($categories as $category) {
         // Look for the deepest path and save.
         if (substr_count($category->getData('path'), '/') > substr_count($path, '/')) {
             $path = $category->getData('path');
             $deepCatId = $category->getId();
         }
     }
     // Load category.
     $category = Mage::getModel('catalog/category')->load($deepCatId);
     // Remove .html from category url_path.
     $categoryPath = str_replace('.html', '', $category->getData('url_path'));
     // Get product url path if set.
     $productUrlPath = $product->getData('url_path');
     // Get product request path if set.
     $productRequestPath = $product->getData('request_path');
     // If URL path is not found, try using the URL key.
     if ($productUrlPath === null && $productRequestPath === null) {
         $productUrlPath = $product->getData('url_key');
     }
     // Now grab only the product path including suffix (if any).
     if ($productUrlPath) {
         $path = explode('/', $productUrlPath);
         $productPath = array_pop($path);
     } elseif ($productRequestPath) {
         $path = explode('/', $productRequestPath);
         $productPath = array_pop($path);
     }
     // Now set product request path to be our full product url including deepest category url path.
     if ($productPath !== false) {
         if ($categoryPath) {
             // Only use the category path is one is found.
             $product->setData('request_path', $categoryPath . '/' . $productPath);
         } else {
             $product->setData('request_path', $productPath);
         }
     }
     return $product->getProductUrl();
 }
开发者ID:purpleweb,项目名称:ImprovedLayeredNavigationFix,代码行数:51,代码来源:Data.php

示例10: getProductData

 /**
  * Create Product array from Mage_Catalog_Model_Product
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getProductData(Mage_Catalog_Model_Product $product)
 {
     try {
         $data = array('url' => $product->getProductUrl(), 'title' => htmlspecialchars($product->getName()), 'spider' => 1, 'price' => $product->getPrice(), 'description' => urlencode($product->getDescription()), 'tags' => htmlspecialchars($product->getMetaKeyword()), 'images' => array(), 'vars' => array('sku' => $product->getSku(), 'storeId' => '', 'typeId' => $product->getTypeId(), 'status' => $product->getStatus(), 'categoryId' => $product->getCategoryId(), 'categoryIds' => $product->getCategoryIds(), 'websiteIds' => $product->getWebsiteIds(), 'storeIds' => $product->getStoreIds(), 'groupPrice' => $product->getGroupPrice(), 'formatedPrice' => $product->getFormatedPrice(), 'calculatedFinalPrice' => $product->getCalculatedFinalPrice(), 'minimalPrice' => $product->getMinimalPrice(), 'specialPrice' => $product->getSpecialPrice(), 'specialFromDate' => $product->getSpecialFromDate(), 'specialToDate' => $product->getSpecialToDate(), 'relatedProductIds' => $product->getRelatedProductIds(), 'upSellProductIds' => $product->getUpSellProductIds(), 'getCrossSellProductIds' => $product->getCrossSellProductIds(), 'isSuperGroup' => $product->isSuperGroup(), 'isGrouped' => $product->isGrouped(), 'isConfigurable' => $product->isConfigurable(), 'isSuper' => $product->isSuper(), 'isSalable' => $product->isSalable(), 'isAvailable' => $product->isAvailable(), 'isVirtual' => $product->isVirtual(), 'isRecurring' => $product->isRecurring(), 'isInStock' => $product->isInStock(), 'weight' => $product->getSku()));
         // Add product images
         if (self::validateProductImage($product->getImage())) {
             $data['images']['full'] = array("url" => $product->getImageUrl());
         }
         if (self::validateProductImage($product->getSmallImage())) {
             $data['images']['smallImage'] = array("url" => $product->getSmallImageUrl($width = 88, $height = 77));
         }
         if (self::validateProductImage($product->getThumbnail())) {
             $data['images']['thumb'] = array("url" => $product->getThumbnailUrl($width = 75, $height = 75));
         }
         return $data;
         return $data;
     } catch (Exception $e) {
         Mage::logException($e);
     }
 }
开发者ID:xiaoguizhidao,项目名称:sailthru-magento-extension,代码行数:26,代码来源:Content.php

示例11: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Google_Service_ShoppingContent_Product $shoppingProduct
  * @return Google_Service_ShoppingContent_Product
  */
 public function convertAttribute($product, $shoppingProduct)
 {
     $parentId = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
     $parentItem = Mage::getModel('catalog/product')->load($parentId);
     $category = Mage::getModel('catalog/category')->load();
     if (!Mage::getStoreConfig('web/seo/use_rewrites')) {
         if ($product->getTypeId() == 'simple' && $parentItem->getTypeId() == 'configurable' || 'bundle' || 'grouped') {
             $url = $parentItem->getProductUrl(false);
         } else {
             $url = $product->getProductUrl(false);
         }
     } else {
         if ($product->getTypeId() == 'simple' && $parentItem->getTypeId() == 'configurable' || 'bundle' || 'grouped') {
             $url = sprintf('%s%s', Mage::getBaseUrl(), $parentItem->getUrlPath($category));
         } else {
             $url = sprintf('%s%s', Mage::getBaseUrl(), $product->getUrlPath($category));
         }
     }
     if ($url) {
         if (!Mage::getStoreConfigFlag('web/url/use_store')) {
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         $config = Mage::getSingleton('googleshoppingapi/config');
         if ($config->getAddUtmSrcGshopping($product->getStoreId())) {
             $url .= '&utm_source=GoogleShopping';
         }
         if ($customUrlParameters = $config->getCustomUrlParameters($product->getStoreId())) {
             $url .= $customUrlParameters;
         }
         $shoppingProduct->setLink($url);
     }
     return $shoppingProduct;
 }
开发者ID:Behunin,项目名称:MagentoExtensions,代码行数:46,代码来源:Link.php

示例12: getAddToCartUrl

 /**
  * Retrieve url for add product to cart
  * Rewrited for Product List and has required options products
  *
  * @param  Mage_Catalog_Model_Product $product
  * @param array $additional
  * @return string
  */
 public function getAddToCartUrl($product, $additional = array())
 {
     if ($product->hasRequiredOptions()) {
         $url = $product->getProductUrl();
         $link = strpos($url, '?') !== false ? '&' : '?';
         return $url . $link . 'options=cart';
     }
     return parent::getAddToCartUrl($product, $additional);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:17,代码来源:Product_List.php

示例13: getObject

 public function getObject(Mage_Catalog_Model_Product $product)
 {
     $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);
     $customData = array('objectID' => $product->getId(), 'name' => $product->getName(), 'url' => $product->getProductUrl(), 'description' => $product->getDescription());
     foreach (array('price', 'price_with_tax', 'special_price_from_date', 'special_price_to_date', 'special_price', 'special_price_with_tax', 'special_price_formated', 'special_price_with_tax_formated', 'price_formated', 'price_with_tax_formated') as $price) {
         $customData[$price] = array();
     }
     $this->handlePrice($product, $customData);
     if ($this->config->isCustomerGroupsEnabled()) {
         foreach ($groups = Mage::getModel('customer/group')->getCollection() as $group) {
             $group_id = (int) $group->getData('customer_group_id');
             $this->handlePrice($product, $customData, $group_id);
         }
     }
     $categories = array();
     $categories_with_path = array();
     foreach ($this->getProductActiveCategories($product, $product->getStoreId()) as $categoryId) {
         $category = Mage::getModel('catalog/category')->load($categoryId);
         $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;
     //array_values($categories_with_path);
     $customData['categories_without_path'] = $categories;
     if (false === isset($defaultData['thumbnail_url'])) {
         try {
             $customData['thumbnail_url'] = $product->getThumbnailUrl();
             $customData['thumbnail_url'] = str_replace(array('https://', 'http://'), '//', $customData['thumbnail_url']);
         } catch (\Exception $e) {
         }
     }
     if (false === isset($defaultData['image_url'])) {
         try {
             $customData['image_url'] = $product->getImageUrl();
             $customData['image_url'] = str_replace(array('https://', 'http://'), '//', $customData['image_url']);
         } catch (\Exception $e) {
         }
     }
     $additionalAttributes = $this->config->getProductAdditionalAttributes($product->getStoreId());
     $sub_products = null;
     if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped') {
         if ($product->getTypeId() == 'grouped') {
             $sub_products = $product->getTypeInstance(true)->getAssociatedProducts($product);
         }
         if ($product->getTypeId() == 'configurable') {
             $sub_products = $product->getTypeInstance(true)->getUsedProducts(null, $product);
         }
         $min = PHP_INT_MAX;
         $max = 0;
         $min_with_tax = PHP_INT_MAX;
         $max_with_tax = 0;
         foreach ($sub_products as $sub_product) {
             $sub_product = Mage::getModel('catalog/product')->load($sub_product->getId());
             $price = $sub_product->getPrice();
             $price_with_tax = Mage::helper('tax')->getPrice($sub_product, $price, true, null, null, null, null, false);
             $min = min($min, $price);
             $max = max($max, $price);
             $min_with_tax = min($min_with_tax, $price_with_tax);
             $max_with_tax = max($max_with_tax, $price_with_tax);
         }
         $customData['min_formated'] = Mage::helper('core')->formatPrice($min, false);
         $customData['max_formated'] = Mage::helper('core')->formatPrice($max, false);
         $customData['min_with_tax_formated'] = Mage::helper('core')->formatPrice($min_with_tax, false);
//.........这里部分代码省略.........
开发者ID:aivoris,项目名称:algoliasearch-magento,代码行数:101,代码来源:Producthelper.php

示例14: getCleanProductUrl

 /**
  * Remove "child_run.php/" from product URLs. This gets around some weirdness in
  * core Magento that adds SCRIPT_NAME to generated URLs.
  *
  * @param Mage_Catalog_Model_Product $product
  * @return string
  */
 public function getCleanProductUrl(Mage_Catalog_Model_Product $product)
 {
     return str_replace("child_run.php/", "", $product->getProductUrl());
 }
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:11,代码来源:Child.php

示例15: redirectToProductUrl

 /**
  * @param Mage_Core_Controller_Varien_Action
  * @param Mage_Catalog_Model_Product
  */
 protected function redirectToProductUrl(Mage_Core_Controller_Varien_Action $controllerAction, Mage_Catalog_Model_Product $product)
 {
     $controllerAction->getResponse()->setRedirect($product->getProductUrl());
 }
开发者ID:ryaan-anthony,项目名称:magento-search-sku-redirect,代码行数:8,代码来源:Observer.php


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