Skip to content

Commit

Permalink
Add helper module to allow easier testing
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k3lm committed Jan 15, 2025
1 parent f07501b commit f01e8e9
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 1 deletion.
68 changes: 68 additions & 0 deletions .docker/magento/HelperModule/Sequra/Helper/Console/Setup.php
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;
}
}
15 changes: 15 additions & 0 deletions .docker/magento/HelperModule/Sequra/Helper/composer.json
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": {}
}
3 changes: 3 additions & 0 deletions .docker/magento/HelperModule/Sequra/Helper/etc/config.xml
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>
5 changes: 5 additions & 0 deletions .docker/magento/HelperModule/Sequra/Helper/etc/crontab.xml
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>
11 changes: 11 additions & 0 deletions .docker/magento/HelperModule/Sequra/Helper/etc/di.xml
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>
3 changes: 3 additions & 0 deletions .docker/magento/HelperModule/Sequra/Helper/etc/events.xml
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>
7 changes: 7 additions & 0 deletions .docker/magento/HelperModule/Sequra/Helper/etc/module.xml
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>
9 changes: 9 additions & 0 deletions .docker/magento/HelperModule/Sequra/Helper/registration.php
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__
);
1 change: 1 addition & 0 deletions .docker/magento/m2-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ if [ ! -f /var/www/html/.post-install-complete ]; then
&& su -s /bin/bash www-data -c "bin/magento config:set dev/template/allow_symlink $M2_ALLOW_SYMLINK" \
&& su -s /bin/bash www-data -c "bin/magento module:enable Sequra_Core" \
&& su -s /bin/bash www-data -c "bin/magento setup:upgrade" \
&& su -s /bin/bash www-data -c "bin/magento sequra-helper:setup" \
&& su -s /bin/bash www-data -c "bin/magento sequra:configure --merchant_ref="$SQ_MERCHANT_REF" --username="$SQ_USER_NAME" --password="$SQ_USER_SECRET" --assets_key="$SQ_ASSETS_KEY" --endpoint="$SQ_ENDPOINT"" || handle_failure

touch /var/www/html/.post-install-complete && echo "✅ Magento 2 installed and configured."
Expand Down
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ M2_ADMIN_PASSWORD="Admin123"
M2_ADMIN_EMAIL="magento@sequra.com"
M2_ADMIN_FIRSTNAME="Admin"
M2_ADMIN_LASTNAME="Admin"
M2_LANGUAGE="en_US"
M2_LANGUAGE="es_ES"
M2_CURRENCY="EUR"
M2_TIMEZONE="Europe/Madrid"

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
volumes:
- m2_html:/var/www/html
- .:/Sequra/Core:ro
- ./.docker/magento/HelperModule/Sequra:/var/www/html/app/code/Sequra
extra_hosts:
- "${M2_HTTP_HOST}:host-gateway"
<<: *env_file
Expand Down

0 comments on commit f01e8e9

Please sign in to comment.