fork download
  1. <?php
  2. /** @var $installer Mage_Catalog_Model_Resource_Setup */
  3. $installer = $this;
  4.  
  5. $installer->startSetup();
  6.  
  7. /**
  8.  * Add attributes to the eav/attribute table
  9.  */
  10. $installer->addAttribute(
  11. Mage_Catalog_Model_Product::ENTITY,'affiliate_link2',
  12. 'type' => 'text',
  13. 'backend' => '',
  14. 'frontend' => '',
  15. 'label' => 'Affiliate Link2',
  16. 'input' => 'text',
  17. 'class' => '',
  18. 'source' => '',
  19. 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
  20. 'visible' => true,
  21. 'required' => true,
  22. 'user_defined' => false,
  23. 'default' => '',
  24. 'searchable' => false,
  25. 'filterable' => false,
  26. 'comparable' => false,
  27. 'visible_on_front' => false,
  28. 'unique' => false,
  29. 'apply_to' => '',
  30. 'is_configurable' => false,
  31. 'used_in_product_listing' => false
  32. )
  33. );
  34.  
  35. $installer->addAttribute(
  36. Mage_Catalog_Model_Product::ENTITY,'affiliate_link3',
  37. 'type' => 'text',
  38. 'backend' => '',
  39. 'frontend' => '',
  40. 'label' => 'Affiliate Link3',
  41. 'input' => 'text',
  42. 'class' => '',
  43. 'source' => '',
  44. 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
  45. 'visible' => true,
  46. 'required' => true,
  47. 'user_defined' => false,
  48. 'default' => '',
  49. 'searchable' => false,
  50. 'filterable' => false,
  51. 'comparable' => false,
  52. 'visible_on_front' => false,
  53. 'unique' => false,
  54. 'apply_to' => '',
  55. 'is_configurable' => false,
  56. 'used_in_product_listing' => false
  57. )
  58. );
  59.  
  60. $defaultSetId = $installer->getAttributeSetId('catalog_product', 'default');
  61.  
  62. $installer->addAttributeGroup(
  63. 'catalog_product',
  64. $defaultSetId,
  65. 'Affiliate Information'
  66. );
  67.  
  68. //find out the id of the new group
  69. $groupId = $installer->getAttributeGroup(
  70. 'catalog_product',
  71. $defaultSetId,
  72. 'Affiliate Information',
  73. 'attribute_group_id'
  74. );
  75.  
  76. $attributeId = $installer->getAttributeId(
  77. 'catalog_product',
  78. 'affiliate_link2'
  79. );
  80.  
  81. if ($attributeId > 0) {
  82. $installer->addAttributeToSet(
  83. 'catalog_product',
  84. $defaultSetId,
  85. $groupId,
  86. $attributeId
  87. );
  88. }
  89.  
  90. $attributeId = $installer->getAttributeId(
  91. 'catalog_product',
  92. 'affiliate_link3'
  93. );
  94. //assign the attribtue to the group and set
  95. if ($attributeId > 0) {
  96. $installer->addAttributeToSet(
  97. 'catalog_product',
  98. $defaultSetId,
  99. $groupId,
  100. $attributeId
  101. );
  102. }
  103.  
  104. $installer->endSetup();
Runtime error #stdin #stdout #stderr 0.02s 24448KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Notice:  Undefined variable: this in /home/NEAB4g/prog.php on line 3
PHP Fatal error:  Call to a member function startSetup() on null in /home/NEAB4g/prog.php on line 5