Skip to content

Commit

Permalink
CmsBlock config source added (Shareable between checkout success and …
Browse files Browse the repository at this point in the history
…firecheckout)
  • Loading branch information
vovayatsyuk committed Nov 18, 2016
1 parent 8370fc0 commit e5b23be
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions app/code/community/TM/Core/Model/System/Config/Source/CmsBlock.php
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;
}
}

0 comments on commit e5b23be

Please sign in to comment.