Create a gist now

Instantly share code, notes, and snippets.

@Vinai /UpgradeData.php Secret
Created Jul 8, 2016

What would you like to do?
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