本文整理汇总了PHP中Mage_Catalog_Model_Product::getUrlPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getUrlPath方法的具体用法?PHP Mage_Catalog_Model_Product::getUrlPath怎么用?PHP Mage_Catalog_Model_Product::getUrlPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product::getUrlPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetUrlPath
public function testGetUrlPath()
{
$this->_model->setUrlPath('test');
$this->assertEquals('test', $this->_model->getUrlPath());
$category = new Mage_Catalog_Model_Category();
$category->setUrlPath('category');
$this->assertEquals('category/test', $this->_model->getUrlPath($category));
}
示例2: testGetUrlPath
public function testGetUrlPath()
{
$this->_model->setUrlPath('test');
$this->assertEquals('test', $this->_model->getUrlPath());
/** @var $category Mage_Catalog_Model_Category */
$category = Mage::getModel('Mage_Catalog_Model_Category');
$category->setUrlPath('category');
$this->assertEquals('category/test', $this->_model->getUrlPath($category));
}
示例3: getFullProductUrl
public static function getFullProductUrl(Mage_Catalog_Model_Product $product, Mage_Catalog_Model_Category $category = null, $mustBeIncludedInNavigation = true)
{
$currentCategory = Mage::registry('current_category');
$catIds = $product->getCategoryIds();
$url = Mage::getModel('core/url_rewrite')->getCollection()->addFilter('is_system', '1')->addFilter('product_id', $product->getId())->addFilter('store_id', Mage::app()->getStore()->getId())->addFieldToFilter('category_id', array('gt' => '0'));
if ($currentCategory && in_array($currentCategory->getId(), $catIds)) {
$catId = $currentCategory->getId();
$url->addFilter('category_id', $catId);
}
$rs = $url->setOrder('url_rewrite_id', 'DESC')->getFirstItem();
if (!$rs->getRequestPath()) {
return $product->getUrlPath();
}
return Mage::getBaseUrl() . $rs->getRequestPath();
}
示例4: 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);
$cCatId = array_reverse($childItem->getCategoryIds());
$pCatId = array_reverse($parentItem->getCategoryIds());
$cCat = Mage::getModel('catalog/category')->load($cCatId[0]);
$pCat = Mage::getModel('catalog/category')->load($pCatId[0]);
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
if (!Mage::getStoreConfig('web/seo/use_rewrites')) {
if ($product->getTypeId() == 'simple' && $parentItem->getTypeId() == 'configurable' || 'bundle' || 'grouped') {
$url = $parentItem->getProductUrl(false);
} else {
$url = $childItem->getProductUrl(false);
}
} else {
if ($product->getTypeId() == 'simple' && $parentItem->getTypeId() == 'configurable' || 'bundle' || 'grouped') {
$url = "{$baseUrl}{$parentItem->getUrlPath($pCat)}";
} else {
$url = "{$baseUrl}{$product->getUrlPath($cCat)}";
}
}
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;
}
示例5: 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;
}
示例6: _getProductUrlPath
/**
* @param Mage_Catalog_Model_Product $product
* @return string
*/
protected function _getProductUrlPath(Mage_Catalog_Model_Product $product)
{
return $product->getUrlPath();
}
示例7: _sendOfferMessages
protected function _sendOfferMessages(Mage_Catalog_Model_Product $product, $performThoroughCheck = false)
{
if ($this->_isValueRegistered('xcom_offer_messages_sent', $product->getId())) {
return;
}
$this->_registerValue('xcom_offer_messages_sent', $product->getId());
$cancelledSids = array();
$createdSids = array();
if ($performThoroughCheck || $product->getIsChangedWebsites()) {
$oldWids = $this->_getRegisterValueForKey('xcom_offer_old_stores', $product->getId());
if (!isset($oldWids)) {
$oldWids = array();
}
$cancelledSids = array_diff($oldWids, $product->getStoreIds());
$createdSids = array_diff($product->getStoreIds(), $oldWids);
}
$updatedSids = array_diff($product->getStoreIds(), $cancelledSids, $createdSids);
// There is a case where product was duplicated and just now a sku was filled in
if ($product->getOrigData()) {
$oldSku = $product->getOrigData('sku');
$sku = $product->getSku();
if (empty($oldSku) && !empty($sku)) {
$createdSids = array_merge($createdSids, $updatedSids);
$updatedSids = array();
}
}
if ($product->dataHasChangedFor('price')) {
foreach ($updatedSids as $sid) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferUpdate/WebStoreOfferPriceUpdated', $offerInputData);
}
}
if ($this->_isValueRegistered('xcom_inventory_updated', $product->getId())) {
foreach ($updatedSids as $sid) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferUpdate/WebStoreOfferQuantityUpdated', $offerInputData);
}
}
if ($product->dataHasChangedFor('visibility') || $product->dataHasChangedFor('status')) {
foreach ($updatedSids as $sid) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferUpdate/WebStoreOfferUpdated', $offerInputData);
}
}
if ($product->dataHasChangedFor('url_key')) {
foreach ($updatedSids as $sid) {
Mage::getModel('xcom_chronicle/product_url_update')->setProductId($product->getEntityId())->setStoreId($sid)->setUrlPath($product->getUrlPath())->save();
}
}
foreach ($createdSids as $sid) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferCreation/WebStoreOfferCreated', $offerInputData);
}
foreach ($cancelledSids as $sid) {
$storeProduct = $this->_getRegisterValueForKey('xcom_offer_old_stores_products', $product->getId() . '_' . $sid);
if (empty($storeProduct)) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
} else {
$offerInputData = array('product' => $storeProduct);
}
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferDeletion/WebStoreOfferDeleted', $offerInputData);
}
}