Skip to content

Commit

Permalink
Remove incorrect order statuses and create new ones (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrzyzewski authored Feb 1, 2021
1 parent ae41f67 commit 1921a30
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Model/Config/Source/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function toOptionArray()
$options = [];
foreach ($collection as $item) {
$options[] = [
'value' => __($item->getData('label')) . Status::STATUS_STATE_SEPARATOR . $item->getState(),
'label' => $item->getState()
'value' => $item->getStatus() . Status::STATUS_STATE_SEPARATOR . $item->getState(),
'label' => __($item->getLabel())
];
}

Expand Down
8 changes: 3 additions & 5 deletions Model/OrderImporter/Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,9 @@ protected function processStatus(OrderInterface $order, CheckoutFormInterface $c
{
$status = $this->status->get($checkoutForm);

if ($status[Status::STATE_KEY] != Order::STATE_NEW) {
$order
->setStatus($status[Status::STATUS_KEY])
->setState($status[Status::STATE_KEY]);
}
$order
->setStatus($status[Status::STATUS_KEY])
->setState($status[Status::STATE_KEY]);

if ($status[Status::PAID_KEY]) {
$this->invoice->create($order);
Expand Down
4 changes: 2 additions & 2 deletions Model/OrderImporter/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Status
const PENDING_STATUS = 'pending';
const PROCESSING_STATUS = 'processing';
const OVERPAYMENT_STATUS_CONFIG_KEY = 'allegro/order/overpayment_status';
const UNDERPAYMENT_STATUS_CONFIG_KEY = 'allegro/order/overpayment_status';
const UNDERPAYMENT_STATUS_CONFIG_KEY = 'allegro/order/underpayment_status';
const STATUS_KEY = 'status';
const STATE_KEY = 'state';
const PAID_KEY = 'paid';
Expand All @@ -40,7 +40,7 @@ public function __construct(ScopeConfigInterface $scopeConfig)
public function get(CheckoutFormInterface $checkoutForm)
{
$paidAmountValue = $checkoutForm->getPayment()->getPaidAmount()->getAmount();
if ($paidAmountValue == 0.) {
if ($paidAmountValue == 0) {
return $this->arrayResponse(self::PENDING_STATUS, Order::STATE_NEW);
}

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ produktu i przesyła go do Allegro w celu aktualizacji.

![stock_inventory_synchronization](README/stockInventorySynchronizationDiagram.png)

Synchronizację stanów magazynowych można włączać lub wyłączać w konfiguracji wtyczki.
Synchronizację stanów magazynowych można włączyć w konfiguracji wtyczki.

## Synchronizacja cen
Wtyczka oferuję również możliwość synchronizacji cen produktów Magento z cenami ofert na Allegro. Każdorazowa zmiana ceny produktu jest przesyłana do odpowiedniej oferty na Allegro. Można ustawić, aby ceny były wyższe na Allegro niż w Magento o odpowiedni procent (procent jest jednakowy dla każdej oferty).

Synchronizację cen można włączyć w konfiguracji wtyczki.
![price_policy_configuration](README/allegroPricePolicyConfiguration.png)

## Integracja zamówień
Po nawiązaniu połączenia sklepu z aplikacją Allegro możemy włączyć w konfiguracji import zamówień.
Expand Down Expand Up @@ -146,7 +152,7 @@ Za pomocą wtyczki możemy wystawiać produkty z Magento na Allegro. Aby to zrob
2. Dodać informacje o [zwrotach](https://allegro.pl/dla-sprzedajacych/warunki-oferty-zwroty-a124GwdXZFA), [reklamacji](https://allegro.pl/dla-sprzedajacych/warunki-oferty-reklamacje-vKgeWL5GnHA) oraz [gwarancji](https://allegro.pl/dla-sprzedajacych/warunki-oferty-gwarancje-9dXYn0VeXHM) na Allegro (wymagane tylko dla konta firmowego)
3. Uzupełnić informacje o loklizacji (Sklepy->Konfiguracja->Allegro->Konfiguracja->Pochodzenie)
![origin_configuration](README/originConfiguration.png)
4. (opcjonalnie) Wybrać atrybuty produktów, z których ma być pobierany kod EAN oraz opis (Sklepy->Konfiguracja->Allegro->Konfiguracja->Tworzenie oferty)
4. (opcjonalnie) Wybrać atrybuty produktów, z których mają być pobierane kod EAN, opis oraz cena (Sklepy->Konfiguracja->Allegro->Konfiguracja->Tworzenie oferty)
![ean_select](README/allegroOfferCreateConfiguration.png)

Po wprowadzeniu wymaganych danych można zacząć wystawiać oferty z poziomu Magento.
Expand Down
Binary file modified README/allegroOfferCreateConfiguration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README/allegroOrderImporterConfiguration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added README/allegroPricePolicyConfiguration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions Setup/Patch/Data/OrderStatuses.php
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();
}
}
5 changes: 3 additions & 2 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<tracking_number_sending_enabled>1</tracking_number_sending_enabled>
<reservations_enabled>1</reservations_enabled>
<reservations_cron_enabled>0</reservations_cron_enabled>
<overpayment_status>Pending:allegro_overpayment</overpayment_status>
<underpayment_status>Pending:allegro_underpayment</underpayment_status>
<overpayment_status>allegro_overpayment:new</overpayment_status>
<underpayment_status>allegro_underpayment:new</underpayment_status>
</order>
<debug_mode>
<debug_mode_enabled>0</debug_mode_enabled>
Expand All @@ -27,6 +27,7 @@
</price_policy>
<offer_create>
<ean_attribute>sku</ean_attribute>
<description_attribute>description</description_attribute>
<price_attribute>price</price_attribute>
</offer_create>
</allegro>
Expand Down
2 changes: 2 additions & 0 deletions i18n/pl_PL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,5 @@
"Creation date","Data utworzenia"
"Cron for cleaning old reservations enabled","Cron do czyszczenia starych rezerwacji jest włączony"
"Cron deletes reservations older than 10 days","Cron usuwa rezerwacje starsze niż 10 dni"
"Allegro underpayment","Allegro niedopłata"
"Allegro overpayment","Allegro nadpłata"

0 comments on commit 1921a30

Please sign in to comment.