如何自定义产品网址? [英] How to customize product URL?

查看:90
本文介绍了如何自定义产品网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何自定义产品URL以在URL部分添加诸如EAN之类的某些属性?例如,我要使网址像`[domain]/cars/[sku]/tata-suv.html

How to customize the product URL to add certain attribute such as EAN on URL part? For example I want make url like `[domain]/cars/[sku]/tata-suv.html

谢谢

推荐答案

所以,我在这里要简短快速.

So, I am gonna be short and quick here.

1)您必须自定义Mage_Catalog_Model_Url::getProductRequestPath.您已经添加了以下语句.

1) You have to customize Mage_Catalog_Model_Url::getProductRequestPath. You have add following statements.

$sku = $product->getSku();
$requestPath = 'cars/' . $sku . "/" . $requestPath;

可以在下面的行之前添加它:

May be Add this just before following line:

if (strlen($requestPath) > self::MAX_REQUEST_PATH_LENGTH + self::ALLOWED_REQUEST_PATH_OVERFLOW) {
    $requestPath = substr($requestPath, 0, self::MAX_REQUEST_PATH_LENGTH);
}

2)自定义集合Mage_Catalog_Model_Resource_Url::_getProducts在选择字段列表中添加sku:

2) Customize the collection Mage_Catalog_Model_Resource_Url::_getProducts add sku in select field list:

$select = $adapter->select()
        ->useStraightJoin(true)
        ->from(array('e' => $this->getTable('catalog/product')), array('entity_id', 'sku'))
        ->join(
            array('w' => $this->getTable('catalog/product_website')),
            'e.entity_id = w.product_id AND w.website_id = :website_id',
            array()
        )
        ->where('e.entity_id > :entity_id')
        ->order('e.entity_id')
        ->limit($this->_productLimit);

注意,array('entity_id', 'sku')

这篇关于如何自定义产品网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆