opencart全部商品自动伪静态

Internet 2010-11-18 19937

将以下代码另存为xml文件,放入vqmod的xml目录下即可

<modification>
<id><![CDATA[Full product url]]></id>
<version><![CDATA[1.0]]></version>
<vqmver><![CDATA[2.3.x]]></vqmver>
<author><![CDATA[Buksas]]></author>
<file name="catalog/controller/product/product.php">
<operation error="log">
<search position="after"><![CDATA[public function index() {]]></search>
<add><![CDATA[if (isset($this->request->get['path'])) {]]></add>
</operation>
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$get_categories = $this->model_catalog_product->getCategories($product_id);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="before"><![CDATA[public function review() {]]></search>
<add><![CDATA[else {
$product_id = $this->request->get['product_id'];
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$get_categories = $this->model_catalog_product->getCategories($product_id);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}
$this->redirect($this->url->link('product/product', 'path='. $full_url .'&product_id=' . $product_id));
}
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $result['product_id'])]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $result['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/product/compare.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][$product_id]]]></search>
<add><![CDATA[$this->load->model('catalog/product'); $this->load->model('catalog/category');
$get_categories = $this->model_catalog_product->getCategories($product_id);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $product_id),]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $product_id),]]></add>
</operation>
</file>
<file name="catalog/controller/product/search.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][]]]></search>
<add><![CDATA[$get_categories = $this->model_catalog_product->getCategories($result['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $result['product_id'] . $url)]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url . '&product_id=' . $result['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/product/special.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$this->load->model('catalog/product'); $this->load->model('catalog/category');
$get_categories = $this->model_catalog_product->getCategories($result['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $result['product_id'] . $url)]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $result['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/module/latest.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$get_categories = $this->model_catalog_product->getCategories($result['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $result['product_id'])]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $result['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/module/special.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$get_categories = $this->model_catalog_product->getCategories($result['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $result['product_id'])]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $result['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/module/featured.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$get_categories = $this->model_catalog_product->getCategories($product_info['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $product_info['product_id'])]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $product_info['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/account/wishlist.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$this->load->model('catalog/product'); $this->load->model('catalog/category');
$get_categories = $this->model_catalog_product->getCategories($product_info['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $product_info['product_id'])]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $product_info['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/checkout/cart.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$this->load->model('catalog/product'); $this->load->model('catalog/category');
$get_categories = $this->model_catalog_product->getCategories($product['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $product['product_id'])]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $product['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/module/cart.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$this->load->model('catalog/product'); $this->load->model('catalog/category');
$get_categories = $this->model_catalog_product->getCategories($product['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $product['product_id'])]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $product['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/checkout/confirm.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$this->load->model('catalog/product'); $this->load->model('catalog/category');
$get_categories = $this->model_catalog_product->getCategories($product['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', 'product_id=' . $product['product_id'])]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $product['product_id'])]]></add>
</operation>
</file>
<file name="catalog/controller/product/manufacturer.php">
<operation error="log">
<search position="before"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$this->load->model('catalog/product'); $this->load->model('catalog/category');
$get_categories = $this->model_catalog_product->getCategories($result['product_id']);
foreach ($get_categories as $cat) {
$cat_id = $cat['category_id']; break;
}
$full_url = $cat_id;
while($cat_id) {
$parent = $this->model_catalog_category->getCategory($cat_id);
$cat_id = $parent['parent_id'];
if ( $cat_id != 0 ) $full_url = $cat_id . "_" . $full_url; else break;
}]]></add>
</operation>
<operation error="log">
<search position="replace"><![CDATA[$this->url->link('product/product', '&manufacturer_id=' . $result['manufacturer_id'] . '&product_id=' . $result['product_id'] . $url)]]></search>
<add><![CDATA[$this->url->link('product/product', 'path='. $full_url .'&product_id=' . $result['product_id'])]]></add>
</operation>
</file>
</modification>