Skip to content

Instantly share code, notes, and snippets.

@jreinke
Last active December 15, 2015 09:19
Show Gist options
  • Save jreinke/5237207 to your computer and use it in GitHub Desktop.
Save jreinke/5237207 to your computer and use it in GitHub Desktop.
Bubble Launcher custom indexer example (customer groups indexation)
<?xml version="1.0" encoding="utf-8"?>
<!-- app/code/local/Namespace/Module/etc/config.xml -->
<config>
<modules>
<Namespace_Module> <!-- module name -->
<version>0.1.0</version>
</Namespace_Module>
</modules>
<global>
<models>
<namespace_module> <!-- used in launcher.xml -->
<class>Namespace_Module_Model</class> <!-- used to find group indexer -->
</namespace_module>
</models>
</global>
</config>
<?php
// app/code/local/Namespace/Module/Model/Indexer/Group.php
class Namespace_Module_Model_Indexer_Group extends Bubble_Launcher_Model_Indexer_Abstract
{
protected function _buildIndexData()
{
$data = array();
$collection = Mage::getModel('customer/group')->getCollection();
$menuLabel = Mage::helper('adminhtml')->__('Customer Groups');
foreach ($collection as $group) {
/** @var $group Mage_Customer_Model_Group */
$title = sprintf('%s', $group->getCustomerGroupCode());
$text = sprintf('%s > %s', $menuLabel, $group->getCustomerGroupCode());
$url = $this->_getUrl('adminhtml/customer_group/edit', array('id' => $group->getId()));
$data[] = $this->_prepareData($title, $text, $url);
}
return $data;
}
public function canIndex()
{
return $this->_isAllowed('customer/group');
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- app/code/local/Namespace/Module/etc/launcher.xml -->
<launcher>
<indexers>
<group> <!-- group is the scope -->
<class>namespace_module/indexer_group</class> <!-- model used for indexation -->
</group>
</indexers>
</launcher>
<?xml version="1.0"?>
<!-- app/etc/modules/Namespace_Module.xml -->
<config>
<modules>
<Namespace_Module>
<active>true</active>
<codePool>local</codePool>
</Namespace_Module>
</modules>
</config>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment