Skip to content

Commit e2af974

Browse files
committed
Squashed 'package/marello/' changes from 8d9827b..dac3d53
dac3d53 - remove disabled code from SalesChannelType form type a8352a6 Merge branch 'feature/magento2-integr' into testmerge-magentoint b9016f8 - removing BC break from order view regarding payments 466b4a1 - fixed issue with Migration where it was trying to create the order table on updating the application while it already exists - fixed issue with association name in the Enum field being inconsistent between the installer and the migration - Added additional enum options such as Box and Pallet 3b67642 MAR10001-931: Update Order and OrderItem entities with additional fields e45d024 MM-26: Test and stabilize product sync feature - Fixed issue with check connection on existing integration - Fixed issue with invalid transformations of pricing value triggers update prices on every save of product form a0b0778 MM-25: Add logic for product prices and inventory synchronization (#50) e3d1dbe MM-13: Implement initial products export (#49) 024bee3 MM-23: Add logic to process changes in integration (#47) 951f48f MM-22: Add logic to process changes in Sales Channel (#46) 006abe2 MM-8: Add logic for tax class dictionary synchronization (#45) f502e9d MM-6: Prepare logic for dictionary synchronization (#40) 46fa924 MM-4: Create Magento2 integration form - Added missed constraints d019c62 MM-4: Create Magento2 integration form git-subtree-dir: package/marello git-subtree-split: dac3d53
1 parent 0434749 commit e2af974

36 files changed

Lines changed: 828 additions & 13 deletions

src/Marello/Bundle/InventoryBundle/Entity/Repository/BalancedInventoryRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function setAclHelper(AclHelper $aclHelper)
3030
*
3131
* @param ProductInterface $product
3232
* @param SalesChannelGroup $group
33-
* @return BalancedInventoryLevel
33+
* @return null|BalancedInventoryLevel
3434
*/
3535
public function findExistingBalancedInventory(ProductInterface $product, SalesChannelGroup $group)
3636
{

src/Marello/Bundle/OrderBundle/Entity/Order.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,48 @@ class Order extends ExtendOrder implements
489489
*/
490490
protected $data = [];
491491

492+
/**
493+
* @var \DateTime
494+
*
495+
* @ORM\Column(name="delivery_date", type="datetime", nullable=true)
496+
* @Oro\ConfigField(
497+
* defaultValues={
498+
* "dataaudit"={
499+
* "auditable"=true
500+
* }
501+
* }
502+
* )
503+
*/
504+
protected $deliveryDate;
505+
506+
/**
507+
* @var string
508+
*
509+
* @ORM\Column(name="order_note",type="text", nullable=true)
510+
* @Oro\ConfigField(
511+
* defaultValues={
512+
* "dataaudit"={
513+
* "auditable"=true
514+
* }
515+
* }
516+
* )
517+
*/
518+
protected $orderNote;
519+
520+
/**
521+
* @var string
522+
*
523+
* @ORM\Column(name="po_number",type="string", nullable=true, length=255)
524+
* @Oro\ConfigField(
525+
* defaultValues={
526+
* "dataaudit"={
527+
* "auditable"=true
528+
* }
529+
* }
530+
* )
531+
*/
532+
protected $poNumber;
533+
492534
/**
493535
* @param AbstractAddress|null $billingAddress
494536
* @param AbstractAddress|null $shippingAddress
@@ -1227,4 +1269,61 @@ public function getData()
12271269
{
12281270
return $this->data;
12291271
}
1272+
1273+
/**
1274+
* @return \DateTime
1275+
*/
1276+
public function getDeliveryDate()
1277+
{
1278+
return $this->deliveryDate;
1279+
}
1280+
1281+
/**
1282+
* @param \DateTime $deliveryDate
1283+
* @return $this
1284+
*/
1285+
public function setDeliveryDate(\DateTime $deliveryDate = null)
1286+
{
1287+
$this->deliveryDate = $deliveryDate;
1288+
1289+
return $this;
1290+
}
1291+
1292+
/**
1293+
* @return string
1294+
*/
1295+
public function getOrderNote()
1296+
{
1297+
return $this->orderNote;
1298+
}
1299+
1300+
/**
1301+
* @param string $orderNote
1302+
* @return $this
1303+
*/
1304+
public function setOrderNote(string $orderNote)
1305+
{
1306+
$this->orderNote = $orderNote;
1307+
1308+
return $this;
1309+
}
1310+
1311+
/**
1312+
* @return string
1313+
*/
1314+
public function getPoNumber()
1315+
{
1316+
return $this->poNumber;
1317+
}
1318+
1319+
/**
1320+
* @param string $poNumber
1321+
* @return $this
1322+
*/
1323+
public function setPoNumber(string $poNumber)
1324+
{
1325+
$this->poNumber = $poNumber;
1326+
1327+
return $this;
1328+
}
12301329
}

src/Marello/Bundle/OrderBundle/Entity/OrderItem.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,22 @@ class OrderItem extends ExtendOrderItem implements
337337
*/
338338
protected $status;
339339

340+
341+
/**
342+
* @var \Extend\Entity\EV_Marello_Product_Unit
343+
* @Oro\ConfigField(
344+
* defaultValues={
345+
* "dataaudit"={
346+
* "auditable"=true
347+
* },
348+
* "importexport"={
349+
* "excluded"=true
350+
* }
351+
* }
352+
* )
353+
*/
354+
protected $productUnit;
355+
340356
/**
341357
* OrderItem constructor.
342358
*/
@@ -742,4 +758,23 @@ public function setStatus($status)
742758

743759
return $this;
744760
}
761+
762+
/**
763+
* @return \Extend\Entity\EV_Marello_Product_Unit
764+
*/
765+
public function getProductUnit()
766+
{
767+
return $this->productUnit;
768+
}
769+
770+
/**
771+
* @param string $productUnit
772+
* @return $this
773+
*/
774+
public function setProductUnit($productUnit)
775+
{
776+
$this->productUnit = $productUnit;
777+
778+
return $this;
779+
}
745780
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Marello\Bundle\OrderBundle\EventListener\Doctrine;
4+
5+
use Doctrine\ORM\Event\LifecycleEventArgs;
6+
use Marello\Bundle\OrderBundle\Entity\OrderItem;
7+
use Marello\Bundle\ProductBundle\Migrations\Data\ORM\LoadProductUnitData;
8+
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper;
9+
use Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper;
10+
11+
class OrderItemProductUnitListener
12+
{
13+
/**
14+
* @var DoctrineHelper
15+
*/
16+
protected $doctrineHelper;
17+
18+
/**
19+
* @param DoctrineHelper $doctrineHelper
20+
*/
21+
public function __construct(DoctrineHelper $doctrineHelper)
22+
{
23+
$this->doctrineHelper = $doctrineHelper;
24+
}
25+
26+
27+
/**
28+
* @param LifecycleEventArgs $args
29+
*/
30+
public function postPersist(LifecycleEventArgs $args)
31+
{
32+
$entity = $args->getEntity();
33+
if ($entity instanceof OrderItem && $entity->getProductUnit() === null) {
34+
$entity->setProductUnit($this->findDefaultProductUnit());
35+
}
36+
}
37+
38+
/**
39+
* @return null|object
40+
*/
41+
private function findDefaultProductUnit()
42+
{
43+
$productUnitClass = ExtendHelper::buildEnumValueClassName(LoadProductUnitData::PRODUCT_UNIT_ENUM_CLASS);
44+
$productUnit = $this->doctrineHelper
45+
->getEntityManagerForClass($productUnitClass)
46+
->getRepository($productUnitClass)
47+
->findOneByDefault(true);
48+
49+
if ($productUnit) {
50+
return $productUnit;
51+
}
52+
53+
return null;
54+
}
55+
}

src/Marello/Bundle/OrderBundle/Form/Type/OrderType.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Form\AbstractType;
1717
use Symfony\Component\Form\CallbackTransformer;
1818
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
19+
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
1920
use Symfony\Component\Form\Extension\Core\Type\TextType;
2021
use Symfony\Component\Form\FormBuilderInterface;
2122
use Symfony\Component\Form\FormEvent;
@@ -98,6 +99,28 @@ public function buildForm(FormBuilderInterface $builder, array $options)
9899
'required' => false
99100
]
100101
)
102+
->add(
103+
'deliveryDate',
104+
OroDateTimeType::class,
105+
[
106+
'required' => false
107+
]
108+
)
109+
->add(
110+
'poNumber',
111+
TextType::class,
112+
[
113+
'label' => 'marello.order.po_number.label',
114+
'required' => false
115+
]
116+
)
117+
->add(
118+
'orderNote',
119+
TextareaType::class,
120+
[
121+
'required' => false
122+
]
123+
)
101124
->add('items', OrderItemCollectionType::class);
102125
$this->addPaymentFields($builder);
103126
$this->addShippingFields($builder, $options['data']);

src/Marello/Bundle/OrderBundle/Migrations/Schema/MarelloOrderBundleInstaller.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class MarelloOrderBundleInstaller implements
4343
*/
4444
public function getMigrationVersion()
4545
{
46-
return 'v1_11';
46+
return 'v1_12';
4747
}
4848

4949
/**
@@ -145,6 +145,9 @@ protected function createMarelloOrderOrderTable(Schema $schema)
145145
$table->addIndex(['billing_address_id'], 'IDX_A619DD6443656FE6', []);
146146
$table->addIndex(['shipping_address_id'], 'IDX_A619DD64B1835C8F', []);
147147
$table->addIndex(['salesChannel_id'], 'IDX_A619DD644C7A5B2E', []);
148+
$table->addColumn('delivery_date', 'datetime', ['notnull' => false]);
149+
$table->addColumn('order_note', 'text', ['notnull' => false]);
150+
$table->addColumn('po_number', 'string', ['length' => 255, 'notnull' => false]);
148151
$table->addIndex(['organization_id']);
149152

150153
$this->activityExtension->addActivityAssociation($schema, 'marello_notification', $table->getName());
@@ -224,6 +227,17 @@ protected function createMarelloOrderOrderItemTable(Schema $schema)
224227
'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
225228
]
226229
);
230+
$this->extendExtension->addEnumField(
231+
$schema,
232+
$table,
233+
'productUnit',
234+
'marello_product_unit',
235+
false,
236+
false,
237+
[
238+
'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
239+
]
240+
);
227241
$table->setPrimaryKey(['id']);
228242
$table->addIndex(['organization_id']);
229243
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Marello\Bundle\OrderBundle\Migrations\Schema\v1_12;
4+
5+
use Doctrine\DBAL\Schema\Schema;
6+
use Oro\Bundle\EntityExtendBundle\EntityConfig\ExtendScope;
7+
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension;
8+
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtensionAwareInterface;
9+
use Oro\Bundle\MigrationBundle\Migration\Migration;
10+
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
11+
12+
class MarelloOrderBundle implements Migration, ExtendExtensionAwareInterface
13+
{
14+
/**
15+
* @var ExtendExtension
16+
*/
17+
protected $extendExtension;
18+
19+
/**
20+
* {@inheritdoc}
21+
*/
22+
public function up(Schema $schema, QueryBag $queries)
23+
{
24+
$this->updateOrderTable($schema);
25+
$this->updateOrderItemTable($schema);
26+
}
27+
28+
private function updateOrderTable(Schema $schema)
29+
{
30+
$table = $schema->getTable('marello_order_order');
31+
$table->addColumn('delivery_date', 'datetime', ['notnull' => false]);
32+
$table->addColumn('order_note', 'text', ['notnull' => false]);
33+
$table->addColumn('po_number', 'string', ['length' => 255, 'notnull' => false]);
34+
}
35+
36+
private function updateOrderItemTable(Schema $schema)
37+
{
38+
$tableName = $this->extendExtension->getNameGenerator()->generateEnumTableName('marello_product_unit');
39+
// enum table is already available and created...
40+
if ($schema->hasTable($tableName)) {
41+
return;
42+
}
43+
44+
$table = $schema->getTable('marello_order_order_item');
45+
$this->extendExtension->addEnumField(
46+
$schema,
47+
$table,
48+
'productUnit',
49+
'marello_product_unit',
50+
false,
51+
false,
52+
[
53+
'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
54+
]
55+
);
56+
}
57+
58+
/**
59+
* Sets the ExtendExtension
60+
*
61+
* @param ExtendExtension $extendExtension
62+
*/
63+
public function setExtendExtension(ExtendExtension $extendExtension)
64+
{
65+
$this->extendExtension = $extendExtension;
66+
}
67+
}

0 commit comments

Comments
 (0)