Skip to content

Commit 1921a30

Browse files
authored
Remove incorrect order statuses and create new ones (#92)
1 parent ae41f67 commit 1921a30

File tree

10 files changed

+99
-13
lines changed

10 files changed

+99
-13
lines changed

Model/Config/Source/State.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function toOptionArray()
3535
$options = [];
3636
foreach ($collection as $item) {
3737
$options[] = [
38-
'value' => __($item->getData('label')) . Status::STATUS_STATE_SEPARATOR . $item->getState(),
39-
'label' => $item->getState()
38+
'value' => $item->getStatus() . Status::STATUS_STATE_SEPARATOR . $item->getState(),
39+
'label' => __($item->getLabel())
4040
];
4141
}
4242

Model/OrderImporter/Creator.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,9 @@ protected function processStatus(OrderInterface $order, CheckoutFormInterface $c
323323
{
324324
$status = $this->status->get($checkoutForm);
325325

326-
if ($status[Status::STATE_KEY] != Order::STATE_NEW) {
327-
$order
328-
->setStatus($status[Status::STATUS_KEY])
329-
->setState($status[Status::STATE_KEY]);
330-
}
326+
$order
327+
->setStatus($status[Status::STATUS_KEY])
328+
->setState($status[Status::STATE_KEY]);
331329

332330
if ($status[Status::PAID_KEY]) {
333331
$this->invoice->create($order);

Model/OrderImporter/Status.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Status
1414
const PENDING_STATUS = 'pending';
1515
const PROCESSING_STATUS = 'processing';
1616
const OVERPAYMENT_STATUS_CONFIG_KEY = 'allegro/order/overpayment_status';
17-
const UNDERPAYMENT_STATUS_CONFIG_KEY = 'allegro/order/overpayment_status';
17+
const UNDERPAYMENT_STATUS_CONFIG_KEY = 'allegro/order/underpayment_status';
1818
const STATUS_KEY = 'status';
1919
const STATE_KEY = 'state';
2020
const PAID_KEY = 'paid';
@@ -40,7 +40,7 @@ public function __construct(ScopeConfigInterface $scopeConfig)
4040
public function get(CheckoutFormInterface $checkoutForm)
4141
{
4242
$paidAmountValue = $checkoutForm->getPayment()->getPaidAmount()->getAmount();
43-
if ($paidAmountValue == 0.) {
43+
if ($paidAmountValue == 0) {
4444
return $this->arrayResponse(self::PENDING_STATUS, Order::STATE_NEW);
4545
}
4646

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ produktu i przesyła go do Allegro w celu aktualizacji.
8181

8282
![stock_inventory_synchronization](README/stockInventorySynchronizationDiagram.png)
8383

84-
Synchronizację stanów magazynowych można włączać lub wyłączać w konfiguracji wtyczki.
84+
Synchronizację stanów magazynowych można włączyć w konfiguracji wtyczki.
85+
86+
## Synchronizacja cen
87+
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).
88+
89+
Synchronizację cen można włączyć w konfiguracji wtyczki.
90+
![price_policy_configuration](README/allegroPricePolicyConfiguration.png)
8591

8692
## Integracja zamówień
8793
Po nawiązaniu połączenia sklepu z aplikacją Allegro możemy włączyć w konfiguracji import zamówień.
@@ -146,7 +152,7 @@ Za pomocą wtyczki możemy wystawiać produkty z Magento na Allegro. Aby to zrob
146152
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)
147153
3. Uzupełnić informacje o loklizacji (Sklepy->Konfiguracja->Allegro->Konfiguracja->Pochodzenie)
148154
![origin_configuration](README/originConfiguration.png)
149-
4. (opcjonalnie) Wybrać atrybuty produktów, z których ma być pobierany kod EAN oraz opis (Sklepy->Konfiguracja->Allegro->Konfiguracja->Tworzenie oferty)
155+
4. (opcjonalnie) Wybrać atrybuty produktów, z których mają być pobierane kod EAN, opis oraz cena (Sklepy->Konfiguracja->Allegro->Konfiguracja->Tworzenie oferty)
150156
![ean_select](README/allegroOfferCreateConfiguration.png)
151157

152158
Po wprowadzeniu wymaganych danych można zacząć wystawiać oferty z poziomu Magento.
9.34 KB
Loading
5.83 KB
Loading
13.7 KB
Loading

Setup/Patch/Data/OrderStatuses.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
4+
namespace Macopedia\Allegro\Setup\Patch\Data;
5+
6+
7+
use Magento\Framework\Setup\ModuleDataSetupInterface;
8+
use Magento\Framework\Setup\Patch\DataPatchInterface;
9+
10+
class OrderStatuses implements DataPatchInterface
11+
{
12+
const ALLEGRO_UNDERPAYMENT_STATUS = 'allegro_underpayment';
13+
const ALLEGRO_OVERPAYMENT_STATUS = 'allegro_overpayment';
14+
15+
/**
16+
* @var ModuleDataSetupInterface
17+
*/
18+
private $moduleDataSetup;
19+
20+
/**
21+
* OrderStatuses constructor.
22+
* @param ModuleDataSetupInterface $moduleDataSetup
23+
*/
24+
public function __construct(ModuleDataSetupInterface $moduleDataSetup) {
25+
$this->moduleDataSetup = $moduleDataSetup;
26+
}
27+
28+
/**
29+
* @return array
30+
*/
31+
public static function getDependencies()
32+
{
33+
return [];
34+
}
35+
36+
/**
37+
* @return array
38+
*/
39+
public function getAliases()
40+
{
41+
return [];
42+
}
43+
44+
/**
45+
* @return OrderStatuses|void
46+
*/
47+
public function apply()
48+
{
49+
$connection = $this->moduleDataSetup->getConnection();
50+
51+
$connection->startSetup();
52+
53+
$sosTable = $this->moduleDataSetup->getTable('sales_order_status');
54+
$sossTable = $this->moduleDataSetup->getTable('sales_order_status_state');
55+
56+
//Remove incorrect statuses
57+
$connection->delete($sossTable, ['state = ?' => self::ALLEGRO_UNDERPAYMENT_STATUS]);
58+
$connection->delete($sossTable, ['state = ?' => self::ALLEGRO_OVERPAYMENT_STATUS]);
59+
60+
$data[] = ['status' => self::ALLEGRO_UNDERPAYMENT_STATUS, 'label' => 'Allegro underpayment'];
61+
$data[] = ['status' => self::ALLEGRO_OVERPAYMENT_STATUS, 'label' => 'Allegro overpayment'];
62+
$connection->insertArray(
63+
$sosTable,
64+
['status', 'label'],
65+
$data
66+
);
67+
68+
$connection->insertArray(
69+
$sossTable,
70+
['status', 'state', 'is_default','visible_on_front'],
71+
[
72+
[self::ALLEGRO_UNDERPAYMENT_STATUS,'new', '0', '1'],
73+
[self::ALLEGRO_OVERPAYMENT_STATUS, 'new', '0', '1']
74+
]
75+
);
76+
77+
$connection->endSetup();
78+
}
79+
}

etc/config.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<tracking_number_sending_enabled>1</tracking_number_sending_enabled>
1717
<reservations_enabled>1</reservations_enabled>
1818
<reservations_cron_enabled>0</reservations_cron_enabled>
19-
<overpayment_status>Pending:allegro_overpayment</overpayment_status>
20-
<underpayment_status>Pending:allegro_underpayment</underpayment_status>
19+
<overpayment_status>allegro_overpayment:new</overpayment_status>
20+
<underpayment_status>allegro_underpayment:new</underpayment_status>
2121
</order>
2222
<debug_mode>
2323
<debug_mode_enabled>0</debug_mode_enabled>
@@ -27,6 +27,7 @@
2727
</price_policy>
2828
<offer_create>
2929
<ean_attribute>sku</ean_attribute>
30+
<description_attribute>description</description_attribute>
3031
<price_attribute>price</price_attribute>
3132
</offer_create>
3233
</allegro>

i18n/pl_PL.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,5 @@
179179
"Creation date","Data utworzenia"
180180
"Cron for cleaning old reservations enabled","Cron do czyszczenia starych rezerwacji jest włączony"
181181
"Cron deletes reservations older than 10 days","Cron usuwa rezerwacje starsze niż 10 dni"
182+
"Allegro underpayment","Allegro niedopłata"
183+
"Allegro overpayment","Allegro nadpłata"

0 commit comments

Comments
 (0)