+ Data patch for the customer EAV attribute +
+ + + \ No newline at end of file diff --git a/resources/fileTemplates/internal/Magento Eav Attribute Data Patch Class.php.ft b/resources/fileTemplates/internal/Magento Eav Attribute Data Patch Class.php.ft new file mode 100644 index 000000000..7c6813869 --- /dev/null +++ b/resources/fileTemplates/internal/Magento Eav Attribute Data Patch Class.php.ft @@ -0,0 +1,87 @@ +moduleDataSetup = $moduleDataSetup; + $this->eavSetupFactory = $eavSetupFactory; + } + + /** + * Run code inside patch + * If code fails, patch must be reverted, in case when we are speaking about schema - then under revert + * means run PatchInterface::revert() + * + * If we speak about data, under revert means: $transaction->rollback() + */ + public function apply() + { + /** @var ${EAV_SETUP} $eavSetup */ + $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); + + $eavSetup->addAttribute( + ${ENTITY_CLASS}::ENTITY, + '${ATTRIBUTE_CODE}', + [ + #set ($attributeSet = ${ATTRIBUTE_SET}) + #foreach ($attribute in $attributeSet.split("->")) + $attribute + #end +] + ); + } + + /** + * Get array of patches that have to be executed prior to this. + * + * Example of implementation: + * + * [ + * \Vendor_Name\Module_Name\Setup\Patch\Patch1::class, + * \Vendor_Name\Module_Name\Setup\Patch\Patch2::class + * ] + * + * @return string[] + */ + public static function getDependencies() + { + return []; + } + + /** + * Get aliases (previous names) for the patch. + * + * @return string[] + */ + public function getAliases() + { + return []; + } +} diff --git a/resources/fileTemplates/internal/Magento Source Model Class.php.ft b/resources/fileTemplates/internal/Magento Source Model Class.php.ft new file mode 100644 index 000000000..108281c0e --- /dev/null +++ b/resources/fileTemplates/internal/Magento Source Model Class.php.ft @@ -0,0 +1,22 @@ + options; + private Map