Create block array

Create array of static block data and iterate through each array using foreach loop as shown below

$blocks = array(
 
    array(
       'title' => 'Get in touch',
       'identifier' => 'get_in_touch',
       'storeId' => $storeId,
       'active' => 1,
       'content' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s,'
       ),
    array(
        'title' => 'Subcategories',
        'identifier' => 'subcategories',
        'storeId' => $storeId,
        'active' => 1,
        'content' => '{{block type="core/template" template="catalog/category/sub.phtml"}}',
        ),
    array(
        'title' => 'Slideshow',
        'identifier' => 'slideshow',
        'storeId' => $storeId,
        'active' => 1,
        'content' => '<ul>
                    <li><img alt="" src="{{media url="wysiwyg/slideshow.jpg"}}" /></li>
                    </ul>'
        )
);

foreach($blocks as $block) {
    createBlock($block);
}

Share this Tutorial