Skip to content

Commit

Permalink
Merge pull request #26 from pagarme/hotfix/PAOP-169-admin-page-and-in…
Browse files Browse the repository at this point in the history
…stall-upgrade-scripts

Fixes admin page behaviour and updates install/upgrade scripts
  • Loading branch information
netorodrigues authored Jun 10, 2021
2 parents d5e967d + 633908b commit bb32b6e
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 1,796 deletions.
2 changes: 1 addition & 1 deletion Concrete/integrityData

Large diffs are not rendered by default.

49 changes: 46 additions & 3 deletions Setup/InstallData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,29 @@
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Customer\Setup\CustomerSetupFactory;

class InstallData implements InstallDataInterface
{

private $customerSetupFactory;
public function __construct(
CustomerSetupFactory $customerSetupFactory
) {
$this->customerSetupFactory = $customerSetupFactory;
}

/**
* {@inheritdoc}
*/
public function install(
ModuleDataSetupInterface $setup,
ModuleContextInterface $context
)
{
) {
$setup->startSetup();
$tableName = $setup->getTable('sales_order_status_state');
$tableName = $setup->getTable(
'sales_order_status_state'
);

if ($setup->getConnection()->isTableExists($tableName) == true) {
$connection = $setup->getConnection();
Expand All @@ -28,6 +37,40 @@ public function install(
$connection->update($tableName, $data, $where);
}

$this->addCustomerIdPagarme($setup);
$setup->endSetup();
}

protected function addCustomerIdPagarme($setup)
{
$setup->startSetup();

$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$attributeCode = 'customer_id_pagarme';
$customerSetup->removeAttribute(\Magento\Customer\Model\Customer::ENTITY, $attributeCode);
$customerSetup->addAttribute(
'customer',
$attributeCode,
[
'label' => 'Customer Id Pagar.me',
'type' => 'varchar',
'input' => 'text',
'required' => false,
'visible' => true,
'system' => false,
'position' => 200,
'sort_order' => 200,
'user_defined' => false,
'default' => '0',
]
);

$eavConfig = $customerSetup->getEavConfig()->getAttribute('customer', $attributeCode);
$eavConfig->setData('used_in_forms', ['adminhtml_customer']);
$eavConfig->save();

$setup->endSetup();

return $setup;
}
}
Loading

0 comments on commit bb32b6e

Please sign in to comment.