i'm using magento 2 path system but it's not working, when i do a setup upgrade it doesn't reach my die, could you explain me why ?
<?php
namespace MyVendor\Company\Setup\Patch\Data;
use Magento\Customer\Model\Customer;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AddCustomerCompanyAttribute implements DataPatchInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;
/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;
/**
* Constructor.
*
* @param ModuleDataSetupInterface $moduleDataSetup
* @param CustomerSetupFactory $customerSetupFactory
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
CustomerSetupFactory $customerSetupFactory
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* {@inheritdoc}
*/
public function apply()
{
die('potato');
$this->moduleDataSetup->getConnection()->startSetup();
$customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
$customerSetup->addAttribute(
Customer::ENTITY,
'company',
[
'type' => 'int',
'label' => 'Company',
'input' => 'select',
'required' => true,
'position' => 30,
'system' => false,
'source_model' => \MyVendor\Company\Model\Customer\Attribute\Source\Company::class
]
);
$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'company')
->addData(
[
'used_in_forms' => [
'adminhtml_customer'
]
]
);
$attribute->save();
$this->moduleDataSetup->getConnection()->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getDependencies()
{
return [];
}
/**
* {@inheritdoc}
*/
public function getAliases()
{
return [];
}
}