有没有办法通过 SQL 语句调用可以在 magento 的后端启动的重新索引?
我有一堆将产品添加到magento的脚本,我们需要在它之后重新索引,我们有一个运行这些脚本的预定作业,我想在它们完成后进行重新索引,这样脚本完成后它总是会重新索引不管它们需要多长时间(有时可能需要几分钟,有时是半小时,具体取决于需要更改、插入或删除哪些数据)
任务调度程序在 Microsoft SQL Server 上,magento 在 MySQL 服务器上(我们显然使用链接服务器)
不,那里没有。
在 Magento 中,“重新索引”意味着“运行 PHP 类列表并运行它们的reindexAll
方法”。索引策略因索引器类型而异。大多数需要读取某种数据,进行程序计算,然后将值插入到平面表中。
例如,目录/URL 重写重新索引器是类
app/code/core/Mage/Catalog/Model/Indexer/Url.php
(alias of catalog/indexer_url, PHP class of Mage_Catalog_Model_Indexer_Url)
其reindxAll
方法包含
public function reindexAll()
{
/** @var $resourceModel Mage_Catalog_Model_Resource_Url */
$resourceModel = Mage::getResourceSingleton('catalog/url');
$resourceModel->beginTransaction();
try {
Mage::getSingleton('catalog/url')->refreshRewrites();
$resourceModel->commit();
} catch (Exception $e) {
$resourceModel->rollBack();
throw $e;
}
}
实际的索引是在refreshRewrites
方法中处理的,它创建了所需的 Magento 重写。