Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <core_block_abstract_to_html_before>
- <observers>
- <something>
- <class>namespace_JsonProductInfo_Model_Observer</class>
- <method>addPositionColumn</method>
- </something>
- </observers>
- </core_block_abstract_to_html_before>
- public function addPositionColumn(Varien_Event_Observer $observer)
- {
- $block = $observer->getEvent()->getBlock();
- if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid) {
- if (!$block->isReadonly()) {
- $block->addColumnAfter(
- 'position_simple',
- array(
- 'header' => Mage::helper('jsonproductinfo')->__('Position'),
- 'type' => 'input',
- 'name' => 'position_simple',
- 'index' => 'position_simple',
- 'sortable' => false,
- ),
- 'name'
- );
- }
- }
- }
- <eav_collection_abstract_load_before>
- <observers>
- <jsonproductinfo>
- <class>namespace_JsonProductInfo_Model_Observer</class>
- <method>addPositionToCatalogProductCollection</method>
- </jsonproductinfo>
- </observers>
- </eav_collection_abstract_load_before>
- public function addPositionToCatalogProductCollection($observer)
- {
- $collection = $observer->getEvent()->getCollection();
- if (!isset($collection)) {
- return;
- }
- $collection->addAttributeToSelect('position_simple');
- }
- $this->addAttribute(
- 'catalog_product',
- 'position_simple',
- array(
- 'group' => 'General',
- 'type' => 'varchar',
- 'input' => 'hidden',
- 'backend' => '',
- 'frontend' => '',
- 'label' => 'Simple Position',
- 'class' => '',
- 'source' => '',
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
- 'visible' => true,
- 'required' => false,
- 'user_defined' => true,
- 'default' => '',
- 'searchable' => false,
- 'filterable' => false,
- 'comparable' => false,
- 'visible_on_front' => false,
- 'visible_in_advanced_search' => false,
- 'unique' => false,
- 'apply_to' => Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
- 'is_configurable' => false,
- )
- );
- protected function _getDefaultConfigurationId() {
- /** @var Mage_Catalog_Model_Product $product */
- $product = Mage::registry('current_product');
- if ($product) {
- return array($product->getData('position_simple'));
- }
- return '';
- }
- ...
- 'values' => $this->_getDefaultConfigurationId(),
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement