简体   繁体   中英

How to disable simple product URL rewrite management by Magento?

I have 3 online stores running on a single Magento installation.

They share over 10.000+ SKU's (I've set them up as simple products), but the only products visible on the frontend are the Grouped Products for each store (which have the SKU's associated to them).

As such, my URL rewrite table is very heavy and while checking Varien Profiler I came across "mage::dispatch::routers_match" which is taking more than 5 seconds to complete. I reckon this is because it's such a large table. So that brings me to my question:

How do I specify which URL's I wan't Magento to rewrite. Is there anyway I can tell it to NOT rewrite simple products URLs? That alone would bring down the table to 1/3rd.

PS: Magento CE 1.7.0.2

Edit:

Thank you Tobias for pointing me in the right direction. I went to app/code/core/Mage/Catalog/Model/Url.php and edited the function refreshProductRewrites to this:

foreach ($products as $product) {
        if($product->getTypeId() == "simple"){
            continue;
        }
        else {
        $this->_refreshProductRewrite($product, $this->_categories[$storeRootCategoryId]);
        foreach ($product->getCategoryIds() as $categoryId) {
            if ($categoryId != $storeRootCategoryId && isset($this->_categories[$categoryId])) {
                if (strpos($this->_categories[$categoryId]['path'], $storeRootCategoryPath . '/') !== 0) {
                    continue;
                }
                $this->_refreshProductRewrite($product, $this->_categories[$categoryId]);
            }
        }
    }
    }

The collection for the products which are stored in core_url_rewrite is generated in Mage_Catalog_Model_Url refreshProductRewrites.

You could rewrite this class and implement your own implementation, which only stores the grouped products.

Another solution is just ignoring the products that have an empty url key.

   protected function _refreshProductRewrite(Varien_Object $product, Varien_Object $category)
   {
   if ($category->getId() == $category->getPath()) {
   return $this;
   }
   if ($product->getUrlKey() != '') {

   $urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey());

You can clear the url keys for the simple products by (check the attribute id):

DELETE FROM catalog_product_entity_varchar WHERE entity_id IN (SELECT entity_id FROM catalog_product_entity WHERE type_id='simple' AND attribute_id='97');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM