|
14 | 14 | use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory;
|
15 | 15 | use Vindi\Payment\Model\Config\Source\BillingCycles;
|
16 | 16 | use Vindi\Payment\Model\Config\Source\Interval;
|
| 17 | +use Vindi\Payment\Model\Config\Source\Plan; |
17 | 18 | use Vindi\Payment\Model\Config\Source\BillingTriggerType;
|
18 | 19 |
|
19 | 20 | /**
|
@@ -78,6 +79,10 @@ public function upgrade(
|
78 | 79 | $this->createPlanAttributeSet();
|
79 | 80 | $this->createProductAttributes();
|
80 | 81 | }
|
| 82 | + |
| 83 | + if (version_compare($context->getVersion(), "1.1.1", "<")) { |
| 84 | + $this->addPlanIdFieldProductAttribute(); |
| 85 | + } |
81 | 86 | }
|
82 | 87 |
|
83 | 88 | /**
|
@@ -271,4 +276,42 @@ private function createProductAttributes()
|
271 | 276 | );
|
272 | 277 | }
|
273 | 278 | }
|
| 279 | + |
| 280 | + private function addPlanIdFieldProductAttribute() |
| 281 | + { |
| 282 | + /** @var EavSetup $eavSetup */ |
| 283 | + $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); |
| 284 | + |
| 285 | + $attribute = $eavSetup->getAttribute(Product::ENTITY, 'vindi_plan_id'); |
| 286 | + if (!$attribute) { |
| 287 | + $eavSetup->addAttribute(Product::ENTITY, 'vindi_plan_id', [ |
| 288 | + 'sort_order' => 1, |
| 289 | + 'type' => 'varchar', |
| 290 | + 'backend' => '', |
| 291 | + 'frontend' => '', |
| 292 | + 'label' => 'Vindi Plan', |
| 293 | + 'input' => 'select', |
| 294 | + 'class' => '', |
| 295 | + 'source' => Plan::class, |
| 296 | + 'global' => ScopedAttributeInterface::SCOPE_GLOBAL, |
| 297 | + 'visible' => true, |
| 298 | + 'required' => false, |
| 299 | + 'user_defined' => true, |
| 300 | + 'default' => null, |
| 301 | + 'searchable' => false, |
| 302 | + 'filterable' => false, |
| 303 | + 'comparable' => false, |
| 304 | + 'visible_on_front' => false, |
| 305 | + 'used_in_product_listing' => false, |
| 306 | + 'unique' => false |
| 307 | + ]); |
| 308 | + |
| 309 | + $eavSetup->addAttributeToGroup( |
| 310 | + Product::ENTITY, |
| 311 | + self::VINDI_PLANOS, |
| 312 | + self::VINDI_PLAN_SETTINGS, |
| 313 | + 'vindi_plan_id' |
| 314 | + ); |
| 315 | + } |
| 316 | + } |
274 | 317 | }
|
0 commit comments