我在一个Magento安装上运行了3个在线商店 .
它们共享超过10,000个SKU(我将它们设置为简单产品),但前端可见的唯一产品是每个商店的分组产品(与SKU相关联) .
因此,我的URL重写表非常繁重,在检查Varien Profiler时,我遇到了“mage :: dispatch :: routers_match”,这需要5秒多的时间才能完成 . 我估计这是因为它是一张如此大的 table . 这让我想到了我的问题:
如何指定我不想重写哪个URL Magento . 无论如何,我可以告诉它不要重写简单的产品网址吗?仅这一点就会使表格下降到1/3 .
PS:Magento CE 1.7.0.2
编辑:
谢谢Tobias指出我正确的方向 . 我去了app / code / core / Mage / Catalog / Model / Url.php,编辑了函数 refreshProductRewrites
:
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]);
}
}
}
}
2 回答
core_url_rewrite 中存储的产品集合在 Mage_Catalog_Model_Url refreshProductRewrites中生成 .
您可以重写此类并实现您自己的实现,该实现仅存储分组的产品 .
另一种解决方案是忽略具有空url键的产品 .
您可以通过(检查属性ID)清除简单产品的URL键:
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');