9 use Magento\Catalog\Setup\CategorySetupFactory;
10 use Magento\Quote\Setup\QuoteSetupFactory;
11 use Magento\Sales\Setup\SalesSetupFactory;
21 private $moduleDataSetup;
26 private $categorySetupFactory;
31 private $quoteSetupFactory;
36 private $salesSetupFactory;
47 CategorySetupFactory $categorySetupFactory,
48 QuoteSetupFactory $quoteSetupFactory,
49 SalesSetupFactory $salesSetupFactory
51 $this->moduleDataSetup = $moduleDataSetup;
52 $this->categorySetupFactory = $categorySetupFactory;
53 $this->quoteSetupFactory = $quoteSetupFactory;
54 $this->salesSetupFactory = $salesSetupFactory;
60 public function apply()
66 $entities = [
'quote',
'quote_address',
'quote_item',
'quote_address_item'];
68 $quoteSetup = $this->quoteSetupFactory->create([
'setup' => $this->moduleDataSetup]);
69 foreach ($entities as
$entity) {
74 $salesSetup = $this->salesSetupFactory->create([
'setup' => $this->moduleDataSetup]);
75 $salesSetup->addAttribute(
'order',
'gift_message_id',
$options);
76 $salesSetup->addAttribute(
'order_item',
'gift_message_id',
$options);
80 $salesSetup->addAttribute(
'order_item',
'gift_message_available',
$options);
82 $catalogSetup = $this->categorySetupFactory->create([
'setup' => $this->moduleDataSetup]);
83 $catalogSetup->addAttribute(
85 'gift_message_available',
87 'group' =>
'Gift Options',
88 'backend' => \
Magento\Catalog\Model\Product\Attribute\Backend\Boolean::class,
90 'label' =>
'Allow Gift Message',
93 'source' => \
Magento\Catalog\Model\Product\Attribute\Source\Boolean::class,
97 'user_defined' =>
false,
100 'input_renderer' => \
Magento\GiftMessage\Block\Adminhtml\Product\Helper\Form\Config::class,
101 'visible_on_front' =>
false,
102 'is_used_in_grid' =>
true,
103 'is_visible_in_grid' =>
false,
104 'is_filterable_in_grid' =>
false,
107 $groupName =
'Autosettings';
112 $catalogSetup->addAttributeToGroup(
__construct(\Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup, CategorySetupFactory $categorySetupFactory, QuoteSetupFactory $quoteSetupFactory, SalesSetupFactory $salesSetupFactory)