Skip to content

Instantly share code, notes, and snippets.

@Vinai
Created July 8, 2016 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vinai/e57e77788951d0e7179aa35e2150bfba to your computer and use it in GitHub Desktop.
Save Vinai/e57e77788951d0e7179aa35e2150bfba to your computer and use it in GitHub Desktop.
Example setup script for the Mage2Kata episode 13: The Event Observer Kata.
<?php
namespace Mage2Kata\EventObserver\Setup;
use Magento\Catalog\Model\Product;
use Magento\Eav\Setup\EavSetup;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;
class UpgradeData implements UpgradeDataInterface
{
/**
* @var EavSetup
*/
private $eavSetup;
public function __construct(EavSetup $eavSetup)
{
$this->eavSetup = $eavSetup;
}
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$this->eavSetup->addAttribute(Product::ENTITY, 'magento_se_points', [
'label' => 'Magento SE Points Value',
'type' => 'int',
'required' => 0,
'user_defined' => 1,
'comparable' => 1,
'visible_on_front' => 1,
'is_configurable' => 0,
'group' => 'Product Details',
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment