Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. <core_block_abstract_to_html_before>
  2. <observers>
  3. <something>
  4. <class>namespace_JsonProductInfo_Model_Observer</class>
  5. <method>addPositionColumn</method>
  6. </something>
  7. </observers>
  8. </core_block_abstract_to_html_before>
  9.  
  10. public function addPositionColumn(Varien_Event_Observer $observer)
  11. {
  12. $block = $observer->getEvent()->getBlock();
  13. if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid) {
  14. if (!$block->isReadonly()) {
  15. $block->addColumnAfter(
  16. 'position_simple',
  17. array(
  18. 'header' => Mage::helper('jsonproductinfo')->__('Position'),
  19. 'type' => 'input',
  20. 'name' => 'position_simple',
  21. 'index' => 'position_simple',
  22. 'sortable' => false,
  23. ),
  24. 'name'
  25. );
  26. }
  27. }
  28. }
  29.  
  30. <eav_collection_abstract_load_before>
  31. <observers>
  32. <jsonproductinfo>
  33. <class>namespace_JsonProductInfo_Model_Observer</class>
  34. <method>addPositionToCatalogProductCollection</method>
  35. </jsonproductinfo>
  36. </observers>
  37. </eav_collection_abstract_load_before>
  38.  
  39. public function addPositionToCatalogProductCollection($observer)
  40. {
  41. $collection = $observer->getEvent()->getCollection();
  42. if (!isset($collection)) {
  43. return;
  44. }
  45. $collection->addAttributeToSelect('position_simple');
  46. }
  47.  
  48. $this->addAttribute(
  49. 'catalog_product',
  50. 'position_simple',
  51. array(
  52. 'group' => 'General',
  53. 'type' => 'varchar',
  54. 'input' => 'hidden',
  55. 'backend' => '',
  56. 'frontend' => '',
  57. 'label' => 'Simple Position',
  58. 'class' => '',
  59. 'source' => '',
  60. 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
  61. 'visible' => true,
  62. 'required' => false,
  63. 'user_defined' => true,
  64. 'default' => '',
  65. 'searchable' => false,
  66. 'filterable' => false,
  67. 'comparable' => false,
  68. 'visible_on_front' => false,
  69. 'visible_in_advanced_search' => false,
  70. 'unique' => false,
  71. 'apply_to' => Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
  72. 'is_configurable' => false,
  73. )
  74. );
  75.  
  76. protected function _getDefaultConfigurationId() {
  77. /** @var Mage_Catalog_Model_Product $product */
  78. $product = Mage::registry('current_product');
  79. if ($product) {
  80. return array($product->getData('position_simple'));
  81. }
  82. return '';
  83. }
  84.  
  85. ...
  86. 'values' => $this->_getDefaultConfigurationId(),
  87. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement