Skip to content

Commit 4793c6b

Browse files
committed
Make using transactions for partial index configurable
1 parent 73224d9 commit 4793c6b

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

app/code/community/Hackathon/AsyncIndex/Model/Manager.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ public function executePartialIndex( Mage_Index_Model_Process $process )
1818
{
1919
/** @var $resourceModel Mage_Index_Model_Resource_Process */
2020
$resourceModel = Mage::getResourceSingleton('index/process');
21-
$resourceModel->beginTransaction();
21+
22+
if (Mage::getStoreConfigFlag('system/asyncindex/use_transations')) {
23+
$resourceModel->beginTransaction();
24+
}
2225

2326
$indexMode = 'schedule';
2427
$pendingMode = 'pending';
@@ -36,11 +39,15 @@ public function executePartialIndex( Mage_Index_Model_Process $process )
3639
if ( count(Mage::getResourceSingleton('index/event')->getUnprocessedEvents($process)) === 0 ) {
3740
$process->changeStatus($pendingMode);
3841
}
39-
$resourceModel->commit();
42+
if (Mage::getStoreConfigFlag('system/asyncindex/use_transations')) {
43+
$resourceModel->commit();
44+
}
4045
}
4146
catch (Exception $e)
4247
{
43-
$resourceModel->rollBack();
48+
if (Mage::getStoreConfigFlag('system/asyncindex/use_transations')) {
49+
$resourceModel->rollBack();
50+
}
4451
throw $e;
4552
}
4653

app/code/community/Hackathon/AsyncIndex/etc/config.xml

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<auto_index>1</auto_index>
9595
<scheduler_cron_expr>*/5 * * * *</scheduler_cron_expr>
9696
<event_limit>100</event_limit>
97+
<use_transactions>1</use_transactions>
9798
</asyncindex>
9899
</system>
99100
</default>

app/code/community/Hackathon/AsyncIndex/etc/system.xml

+9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@
5959
<show_in_website>0</show_in_website>
6060
<show_in_store>0</show_in_store>
6161
</blacklist_indexes>
62+
<use_transactions>
63+
<label>Use Transactions for Partial Index</label>
64+
<frontend_type>select</frontend_type>
65+
<source_model>adminhtml/system_config_source_yesno</source_model>
66+
<sort_order>60</sort_order>
67+
<show_in_default>1</show_in_default>
68+
<show_in_website>0</show_in_website>
69+
<show_in_store>0</show_in_store>
70+
</use_transactions>
6271
</fields>
6372
</asyncindex>
6473
</groups>

0 commit comments

Comments
 (0)