gpt4 book ai didi

magento - 从 sitemap.xml 生成中排除特定页面

转载 作者:行者123 更新时间:2023-12-02 10:44:33 25 4
gpt4 key购买 nike

我想知道是否有一种方法可以排除某个特定的 CMS 页面被添加/包含在 Magento 的站点地图生成中。

一些专家的建议将不胜感激。

最佳答案

例如,通过重写Mage_Sitemap_Model_Resource_Cms_Page::getCollection,如下所示:

public function getCollection($storeId)
{
$pages = array();

$select = $this->_getWriteAdapter()->select()
->from(array('main_table' => $this->getMainTable()), array($this->getIdFieldName(), 'identifier AS url'))
->join(
array('store_table' => $this->getTable('cms/page_store')),
'main_table.page_id=store_table.page_id',
array()
)
// --- exclude single CMS page "enable-cookies"
->where('main_table.identifier<>"enable-cookies"')
// --- exclude multiple CMS pages "home", "enable-cookies"
// ->where('main_table.identifier NOT IN (?)', array('home', 'enable-cookies'))
// ---
->where('main_table.is_active=1')
->where('store_table.store_id IN(?)', array(0, $storeId));
$query = $this->_getWriteAdapter()->query($select);
while ($row = $query->fetch()) {
if ($row['url'] == Mage_Cms_Model_Page::NOROUTE_PAGE_ID) {
continue;
}
$page = $this->_prepareObject($row);
$pages[$page->getId()] = $page;
}

return $pages;
}

如果您还不知道如何重写 Magento 模型类,请查看 Alan Storm 的文章 Magento for Developers: Part 1 - Introduction to Magento ,特别是“模型”和“类覆盖”部分。

关于magento - 从 sitemap.xml 生成中排除特定页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12528883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com