Skip to content

Commit

Permalink
Squashed 'package/marello/' changes from 8d9827b..dac3d53
Browse files Browse the repository at this point in the history
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
  • Loading branch information
24198 committed Jul 8, 2020
1 parent 0434749 commit e2af974
Show file tree
Hide file tree
Showing 36 changed files with 828 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setAclHelper(AclHelper $aclHelper)
*
* @param ProductInterface $product
* @param SalesChannelGroup $group
* @return BalancedInventoryLevel
* @return null|BalancedInventoryLevel
*/
public function findExistingBalancedInventory(ProductInterface $product, SalesChannelGroup $group)
{
Expand Down
99 changes: 99 additions & 0 deletions src/Marello/Bundle/OrderBundle/Entity/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,48 @@ class Order extends ExtendOrder implements
*/
protected $data = [];

/**
* @var \DateTime
*
* @ORM\Column(name="delivery_date", type="datetime", nullable=true)
* @Oro\ConfigField(
* defaultValues={
* "dataaudit"={
* "auditable"=true
* }
* }
* )
*/
protected $deliveryDate;

/**
* @var string
*
* @ORM\Column(name="order_note",type="text", nullable=true)
* @Oro\ConfigField(
* defaultValues={
* "dataaudit"={
* "auditable"=true
* }
* }
* )
*/
protected $orderNote;

/**
* @var string
*
* @ORM\Column(name="po_number",type="string", nullable=true, length=255)
* @Oro\ConfigField(
* defaultValues={
* "dataaudit"={
* "auditable"=true
* }
* }
* )
*/
protected $poNumber;

/**
* @param AbstractAddress|null $billingAddress
* @param AbstractAddress|null $shippingAddress
Expand Down Expand Up @@ -1227,4 +1269,61 @@ public function getData()
{
return $this->data;
}

/**
* @return \DateTime
*/
public function getDeliveryDate()
{
return $this->deliveryDate;
}

/**
* @param \DateTime $deliveryDate
* @return $this
*/
public function setDeliveryDate(\DateTime $deliveryDate = null)
{
$this->deliveryDate = $deliveryDate;

return $this;
}

/**
* @return string
*/
public function getOrderNote()
{
return $this->orderNote;
}

/**
* @param string $orderNote
* @return $this
*/
public function setOrderNote(string $orderNote)
{
$this->orderNote = $orderNote;

return $this;
}

/**
* @return string
*/
public function getPoNumber()
{
return $this->poNumber;
}

/**
* @param string $poNumber
* @return $this
*/
public function setPoNumber(string $poNumber)
{
$this->poNumber = $poNumber;

return $this;
}
}
35 changes: 35 additions & 0 deletions src/Marello/Bundle/OrderBundle/Entity/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,22 @@ class OrderItem extends ExtendOrderItem implements
*/
protected $status;


/**
* @var \Extend\Entity\EV_Marello_Product_Unit
* @Oro\ConfigField(
* defaultValues={
* "dataaudit"={
* "auditable"=true
* },
* "importexport"={
* "excluded"=true
* }
* }
* )
*/
protected $productUnit;

/**
* OrderItem constructor.
*/
Expand Down Expand Up @@ -742,4 +758,23 @@ public function setStatus($status)

return $this;
}

/**
* @return \Extend\Entity\EV_Marello_Product_Unit
*/
public function getProductUnit()
{
return $this->productUnit;
}

/**
* @param string $productUnit
* @return $this
*/
public function setProductUnit($productUnit)
{
$this->productUnit = $productUnit;

return $this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Marello\Bundle\OrderBundle\EventListener\Doctrine;

use Doctrine\ORM\Event\LifecycleEventArgs;
use Marello\Bundle\OrderBundle\Entity\OrderItem;
use Marello\Bundle\ProductBundle\Migrations\Data\ORM\LoadProductUnitData;
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper;
use Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper;

class OrderItemProductUnitListener
{
/**
* @var DoctrineHelper
*/
protected $doctrineHelper;

/**
* @param DoctrineHelper $doctrineHelper
*/
public function __construct(DoctrineHelper $doctrineHelper)
{
$this->doctrineHelper = $doctrineHelper;
}


/**
* @param LifecycleEventArgs $args
*/
public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof OrderItem && $entity->getProductUnit() === null) {
$entity->setProductUnit($this->findDefaultProductUnit());
}
}

/**
* @return null|object
*/
private function findDefaultProductUnit()
{
$productUnitClass = ExtendHelper::buildEnumValueClassName(LoadProductUnitData::PRODUCT_UNIT_ENUM_CLASS);
$productUnit = $this->doctrineHelper
->getEntityManagerForClass($productUnitClass)
->getRepository($productUnitClass)
->findOneByDefault(true);

if ($productUnit) {
return $productUnit;
}

return null;
}
}
23 changes: 23 additions & 0 deletions src/Marello/Bundle/OrderBundle/Form/Type/OrderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
Expand Down Expand Up @@ -98,6 +99,28 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'required' => false
]
)
->add(
'deliveryDate',
OroDateTimeType::class,
[
'required' => false
]
)
->add(
'poNumber',
TextType::class,
[
'label' => 'marello.order.po_number.label',
'required' => false
]
)
->add(
'orderNote',
TextareaType::class,
[
'required' => false
]
)
->add('items', OrderItemCollectionType::class);
$this->addPaymentFields($builder);
$this->addShippingFields($builder, $options['data']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MarelloOrderBundleInstaller implements
*/
public function getMigrationVersion()
{
return 'v1_11';
return 'v1_12';
}

/**
Expand Down Expand Up @@ -145,6 +145,9 @@ protected function createMarelloOrderOrderTable(Schema $schema)
$table->addIndex(['billing_address_id'], 'IDX_A619DD6443656FE6', []);
$table->addIndex(['shipping_address_id'], 'IDX_A619DD64B1835C8F', []);
$table->addIndex(['salesChannel_id'], 'IDX_A619DD644C7A5B2E', []);
$table->addColumn('delivery_date', 'datetime', ['notnull' => false]);
$table->addColumn('order_note', 'text', ['notnull' => false]);
$table->addColumn('po_number', 'string', ['length' => 255, 'notnull' => false]);
$table->addIndex(['organization_id']);

$this->activityExtension->addActivityAssociation($schema, 'marello_notification', $table->getName());
Expand Down Expand Up @@ -224,6 +227,17 @@ protected function createMarelloOrderOrderItemTable(Schema $schema)
'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
]
);
$this->extendExtension->addEnumField(
$schema,
$table,
'productUnit',
'marello_product_unit',
false,
false,
[
'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
]
);
$table->setPrimaryKey(['id']);
$table->addIndex(['organization_id']);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Marello\Bundle\OrderBundle\Migrations\Schema\v1_12;

use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\EntityExtendBundle\EntityConfig\ExtendScope;
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension;
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtensionAwareInterface;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class MarelloOrderBundle implements Migration, ExtendExtensionAwareInterface
{
/**
* @var ExtendExtension
*/
protected $extendExtension;

/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->updateOrderTable($schema);
$this->updateOrderItemTable($schema);
}

private function updateOrderTable(Schema $schema)
{
$table = $schema->getTable('marello_order_order');
$table->addColumn('delivery_date', 'datetime', ['notnull' => false]);
$table->addColumn('order_note', 'text', ['notnull' => false]);
$table->addColumn('po_number', 'string', ['length' => 255, 'notnull' => false]);
}

private function updateOrderItemTable(Schema $schema)
{
$tableName = $this->extendExtension->getNameGenerator()->generateEnumTableName('marello_product_unit');
// enum table is already available and created...
if ($schema->hasTable($tableName)) {
return;
}

$table = $schema->getTable('marello_order_order_item');
$this->extendExtension->addEnumField(
$schema,
$table,
'productUnit',
'marello_product_unit',
false,
false,
[
'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
]
);
}

/**
* Sets the ExtendExtension
*
* @param ExtendExtension $extendExtension
*/
public function setExtendExtension(ExtendExtension $extendExtension)
{
$this->extendExtension = $extendExtension;
}
}
Loading

0 comments on commit e2af974

Please sign in to comment.