-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper module to allow easier testing
- Loading branch information
Showing
11 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
.docker/magento/HelperModule/Sequra/Helper/Console/Setup.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Copyright © 2017 SeQura Engineering. All rights reserved. | ||
*/ | ||
|
||
namespace Sequra\Helper\Console; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Console command to trigger DR report | ||
*/ | ||
class Setup extends Command | ||
{ | ||
/** | ||
* Command name | ||
*/ | ||
const NAME = 'sequra-helper:setup'; | ||
/** | ||
* Initialize triggerreport command | ||
* | ||
* @return void | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->setName(self::NAME) | ||
->setDescription('Setup data for quick testing'); | ||
parent::configure(); | ||
} | ||
/** | ||
* Execute command. | ||
* | ||
* @param InputInterface $input InputInterface | ||
* @param OutputInterface $output OutputInterface | ||
* | ||
* @return int 0 if everything went fine, or an exit code | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | ||
$customerRepository = $objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); | ||
|
||
$customer = $customerRepository->getById(1); | ||
$customer->setLastname('Costello Costello'); | ||
$addresses = $customer->getAddresses(); | ||
if (!empty($addresses)) { | ||
$address = reset($addresses); | ||
$address->setStreet(['Nueva Calle', 'Piso 2']); | ||
$address->setCity('Barcelona'); | ||
$address->setPostcode('08010'); | ||
$address->setCountryId('ES'); | ||
$address->setTelephone('666666666'); | ||
$regionFactory = $objectManager->create(\Magento\Directory\Model\RegionFactory::class); | ||
$region = $regionFactory->create()->loadByName('Barcelona','ES'); | ||
if ($region->getId()) { | ||
$address->setRegionId($region->getId()); | ||
} | ||
} | ||
|
||
$customerRepository->save($customer); | ||
$output->writeln("Dirección actualizada correctamente"); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "sequra/magento2-helper", | ||
"type": "magento2-module", | ||
"autoload": { | ||
"psr-4": { | ||
"Sequra\\Helper\\": "" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Sequra Engineering" | ||
} | ||
], | ||
"require": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> | ||
<group id="default"> | ||
</group> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<!-- Commandline option to triggerrerport and update orders--> | ||
<type name="Magento\Framework\Console\CommandList"> | ||
<arguments> | ||
<argument name="commands" xsi:type="array"> | ||
<item name="Setup" xsi:type="object">Sequra\Helper\Console\Setup</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Sequra_Helper" setup_version="1.0.0"> | ||
<sequence> | ||
</sequence> | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register( | ||
ComponentRegistrar::MODULE, | ||
'Sequra_Helper', | ||
__DIR__ | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters