-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CmsBlock config source added (Shareable between checkout success and …
…firecheckout)
- Loading branch information
1 parent
8370fc0
commit e5b23be
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
app/code/community/TM/Core/Model/System/Config/Source/CmsBlock.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* Cms block names with store ids | ||
*/ | ||
class TM_Core_Model_System_Config_Source_CmsBlock | ||
{ | ||
public function toOptionArray() | ||
{ | ||
$collection = Mage::getResourceModel('cms/block_collection') | ||
->addFieldToFilter('is_active', 1) | ||
->addOrder('title', 'ASC'); | ||
|
||
$collection->getSelect() | ||
->join( | ||
array('store_table' => $collection->getTable('cms/block_store')), | ||
'main_table.block_id = store_table.block_id', | ||
array( | ||
'store_ids' => new Zend_Db_Expr( | ||
"GROUP_CONCAT(store_table.store_id ORDER BY store_table.store_id ASC SEPARATOR ', ')" | ||
) | ||
) | ||
) | ||
->group('main_table.block_id'); | ||
|
||
$blocks = array(); | ||
foreach ($collection as $block) { | ||
$blocks[] = array( | ||
'label' => $block->getTitle() . " (" . $block->getStoreIds() . ")", | ||
'value' => $block->getId() | ||
); | ||
} | ||
array_unshift($blocks, array( | ||
'value' => 0, | ||
'label' => Mage::helper('adminhtml')->__('No') | ||
)); | ||
return $blocks; | ||
} | ||
} |