-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove incorrect order statuses and create new ones (#92)
- Loading branch information
1 parent
ae41f67
commit 1921a30
Showing
10 changed files
with
99 additions
and
13 deletions.
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,79 @@ | ||
<?php | ||
|
||
|
||
namespace Macopedia\Allegro\Setup\Patch\Data; | ||
|
||
|
||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
use Magento\Framework\Setup\Patch\DataPatchInterface; | ||
|
||
class OrderStatuses implements DataPatchInterface | ||
{ | ||
const ALLEGRO_UNDERPAYMENT_STATUS = 'allegro_underpayment'; | ||
const ALLEGRO_OVERPAYMENT_STATUS = 'allegro_overpayment'; | ||
|
||
/** | ||
* @var ModuleDataSetupInterface | ||
*/ | ||
private $moduleDataSetup; | ||
|
||
/** | ||
* OrderStatuses constructor. | ||
* @param ModuleDataSetupInterface $moduleDataSetup | ||
*/ | ||
public function __construct(ModuleDataSetupInterface $moduleDataSetup) { | ||
$this->moduleDataSetup = $moduleDataSetup; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public static function getDependencies() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getAliases() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @return OrderStatuses|void | ||
*/ | ||
public function apply() | ||
{ | ||
$connection = $this->moduleDataSetup->getConnection(); | ||
|
||
$connection->startSetup(); | ||
|
||
$sosTable = $this->moduleDataSetup->getTable('sales_order_status'); | ||
$sossTable = $this->moduleDataSetup->getTable('sales_order_status_state'); | ||
|
||
//Remove incorrect statuses | ||
$connection->delete($sossTable, ['state = ?' => self::ALLEGRO_UNDERPAYMENT_STATUS]); | ||
$connection->delete($sossTable, ['state = ?' => self::ALLEGRO_OVERPAYMENT_STATUS]); | ||
|
||
$data[] = ['status' => self::ALLEGRO_UNDERPAYMENT_STATUS, 'label' => 'Allegro underpayment']; | ||
$data[] = ['status' => self::ALLEGRO_OVERPAYMENT_STATUS, 'label' => 'Allegro overpayment']; | ||
$connection->insertArray( | ||
$sosTable, | ||
['status', 'label'], | ||
$data | ||
); | ||
|
||
$connection->insertArray( | ||
$sossTable, | ||
['status', 'state', 'is_default','visible_on_front'], | ||
[ | ||
[self::ALLEGRO_UNDERPAYMENT_STATUS,'new', '0', '1'], | ||
[self::ALLEGRO_OVERPAYMENT_STATUS, 'new', '0', '1'] | ||
] | ||
); | ||
|
||
$connection->endSetup(); | ||
} | ||
} |
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