From 9c39a707f3415a5d231c9f5e811d278f1eba8062 Mon Sep 17 00:00:00 2001 From: Yurii Muratov Date: Thu, 6 Aug 2015 17:06:16 +0300 Subject: [PATCH 1/6] OEE-642: Add organization fields to the Cart and Order items --- .../Bundle/MagentoBundle/Entity/CartItem.php | 38 +++++++++++++++ .../Bundle/MagentoBundle/Entity/OrderItem.php | 38 +++++++++++++++ .../ImportExport/Strategy/CartStrategy.php | 1 + .../ImportExport/Strategy/OrderStrategy.php | 1 + .../Schema/OroCRMMagentoBundleInstaller.php | 16 +++++++ .../Schema/v1_35/ItemsOrganizationOwner.php | 47 +++++++++++++++++++ .../Resources/translations/messages.en.yml | 2 + 7 files changed, 143 insertions(+) create mode 100644 src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/v1_35/ItemsOrganizationOwner.php diff --git a/src/OroCRM/Bundle/MagentoBundle/Entity/CartItem.php b/src/OroCRM/Bundle/MagentoBundle/Entity/CartItem.php index c5a7ae486bd..71ca03619ed 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Entity/CartItem.php +++ b/src/OroCRM/Bundle/MagentoBundle/Entity/CartItem.php @@ -4,6 +4,7 @@ use Doctrine\ORM\Mapping as ORM; +use Oro\Bundle\OrganizationBundle\Entity\Organization; use OroCRM\Bundle\MagentoBundle\Model\ExtendCartItem; use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config; @@ -21,6 +22,11 @@ * "entity"={ * "icon"="icon-shopping-cart" * }, + * "ownership"={ + * "owner_type"="ORGANIZATION", + * "owner_field_name"="owner", + * "owner_column_name"="owner_id" + * }, * "security"={ * "type"="ACL", * "group_name"="" @@ -154,6 +160,14 @@ class CartItem extends ExtendCartItem implements OriginAwareInterface, Integrati */ protected $removed = false; + /** + * @var Organization + * + * @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization") + * @ORM\JoinColumn(name="owner_id", referencedColumnName="id", onDelete="SET NULL") + */ + protected $owner; + /** * @param float $customPrice * @@ -453,4 +467,28 @@ public function setRemoved($removed) return $this; } + + /** + * Set owner + * + * @param Organization $owner + * + * @return $this + */ + public function setOwner(Organization $owner = null) + { + $this->owner = $owner; + + return $this; + } + + /** + * Get owner + * + * @return Organization + */ + public function getOwner() + { + return $this->owner; + } } diff --git a/src/OroCRM/Bundle/MagentoBundle/Entity/OrderItem.php b/src/OroCRM/Bundle/MagentoBundle/Entity/OrderItem.php index 2ffcbd9acc6..8cbe49a56bb 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Entity/OrderItem.php +++ b/src/OroCRM/Bundle/MagentoBundle/Entity/OrderItem.php @@ -6,6 +6,7 @@ use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config; +use Oro\Bundle\OrganizationBundle\Entity\Organization; use OroCRM\Bundle\MagentoBundle\Model\ExtendOrderItem; /** @@ -16,6 +17,11 @@ * "entity"={ * "icon"="icon-list-alt" * }, + * "ownership"={ + * "owner_type"="ORGANIZATION", + * "owner_field_name"="owner", + * "owner_column_name"="owner_id" + * }, * "security"={ * "type"="ACL", * "group_name"="" @@ -79,6 +85,14 @@ class OrderItem extends ExtendOrderItem implements IntegrationAwareInterface, Or */ protected $discountPercent; + /** + * @var Organization + * + * @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization") + * @ORM\JoinColumn(name="owner_id", referencedColumnName="id", onDelete="SET NULL") + */ + protected $owner; + /** Do not needed in magento order item, because magento api does not bring it up */ protected $cost; @@ -181,4 +195,28 @@ public function getDiscountPercent() { return $this->discountPercent; } + + /** + * Set owner + * + * @param Organization $owner + * + * @return OrderItem + */ + public function setOwner(Organization $owner = null) + { + $this->owner = $owner; + + return $this; + } + + /** + * Get owner + * + * @return Organization + */ + public function getOwner() + { + return $this->owner; + } } diff --git a/src/OroCRM/Bundle/MagentoBundle/ImportExport/Strategy/CartStrategy.php b/src/OroCRM/Bundle/MagentoBundle/ImportExport/Strategy/CartStrategy.php index 39b97b2a2e0..f2b4d882d02 100644 --- a/src/OroCRM/Bundle/MagentoBundle/ImportExport/Strategy/CartStrategy.php +++ b/src/OroCRM/Bundle/MagentoBundle/ImportExport/Strategy/CartStrategy.php @@ -120,6 +120,7 @@ protected function updateCustomer(Cart $cart) protected function updateCartItems(Cart $cart) { foreach ($cart->getCartItems() as $cartItem) { + $cartItem->setOwner($cart->getOrganization()); $cartItem->setCart($cart); } diff --git a/src/OroCRM/Bundle/MagentoBundle/ImportExport/Strategy/OrderStrategy.php b/src/OroCRM/Bundle/MagentoBundle/ImportExport/Strategy/OrderStrategy.php index fe8a54406ca..adc1c3021a2 100644 --- a/src/OroCRM/Bundle/MagentoBundle/ImportExport/Strategy/OrderStrategy.php +++ b/src/OroCRM/Bundle/MagentoBundle/ImportExport/Strategy/OrderStrategy.php @@ -118,6 +118,7 @@ protected function processCart(Order $entity) protected function processItems(Order $order) { foreach ($order->getItems() as $item) { + $item->setOwner($order->getOrganization()); $item->setOrder($order); } diff --git a/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/OroCRMMagentoBundleInstaller.php b/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/OroCRMMagentoBundleInstaller.php index 93a1c8daa80..c2a253a02b2 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/OroCRMMagentoBundleInstaller.php +++ b/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/OroCRMMagentoBundleInstaller.php @@ -451,7 +451,9 @@ protected function createOrocrmMagentoCartItemTable(Schema $schema) $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); $table->addColumn('channel_id', 'integer', ['notnull' => false]); $table->addColumn('is_removed', 'boolean', ['notnull' => true, 'default' => false]); + $table->addColumn('owner_id', 'integer', ['notnull' => false]); $table->addIndex(['cart_id'], 'IDX_A73DC8621AD5CDBF', []); + $table->addIndex(['owner_id'], 'IDX_A73DC8627E3C61F9', []); $table->setPrimaryKey(['id']); $table->addIndex(['origin_id'], 'magecartitem_origin_idx', []); $table->addIndex(['sku'], 'magecartitem_sku_idx', []); @@ -800,7 +802,9 @@ protected function createOrocrmMagentoOrderItemsTable(Schema $schema) $table->addColumn('row_total', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); $table->addColumn('channel_id', 'integer', ['notnull' => false]); + $table->addColumn('owner_id', 'integer', ['notnull' => false]); $table->addIndex(['order_id'], 'IDX_3135EFF68D9F6D38', []); + $table->addIndex(['owner_id'], 'IDX_3135EFF67E3C61F9', []); $table->setPrimaryKey(['id']); } @@ -1086,6 +1090,12 @@ protected function addOrocrmMagentoCartItemForeignKeys(Schema $schema) ['id'], ['onDelete' => 'SET NULL'] ); + $table->addForeignKeyConstraint( + $schema->getTable('oro_organization'), + ['owner_id'], + ['id'], + ['onDelete' => 'SET NULL'] + ); } /** @@ -1438,6 +1448,12 @@ protected function addOrocrmMagentoOrderItemsForeignKeys(Schema $schema) ['id'], ['onDelete' => 'SET NULL'] ); + $table->addForeignKeyConstraint( + $schema->getTable('oro_organization'), + ['owner_id'], + ['id'], + ['onDelete' => 'SET NULL'] + ); } /** diff --git a/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/v1_35/ItemsOrganizationOwner.php b/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/v1_35/ItemsOrganizationOwner.php new file mode 100644 index 00000000000..dbfad7ed877 --- /dev/null +++ b/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/v1_35/ItemsOrganizationOwner.php @@ -0,0 +1,47 @@ +getTable('orocrm_magento_order_items'); + $table->addColumn('owner_id', 'integer', ['notnull' => false]); + $table->addIndex(['owner_id'], 'IDX_3135EFF67E3C61F9', []); + $table->addForeignKeyConstraint( + $schema->getTable('oro_organization'), + ['owner_id'], + ['id'], + ['onDelete' => 'SET NULL'] + ); + + $queries->addPostQuery( + 'UPDATE orocrm_magento_order_items itm '. + 'SET owner_id = (SELECT organization_id FROM orocrm_magento_order WHERE itm.order_id = id)' + ); + + $table = $schema->getTable('orocrm_magento_cart_item'); + $table->addColumn('owner_id', 'integer', ['notnull' => false]); + $table->addIndex(['owner_id'], 'IDX_A73DC8627E3C61F9', []); + $table->addForeignKeyConstraint( + $schema->getTable('oro_organization'), + ['owner_id'], + ['id'], + ['onDelete' => 'SET NULL'] + ); + + $queries->addPostQuery( + 'UPDATE orocrm_magento_cart_item itm '. + 'SET owner_id = (SELECT organization_id FROM orocrm_magento_cart WHERE itm.cart_id = id)' + ); + } +} diff --git a/src/OroCRM/Bundle/MagentoBundle/Resources/translations/messages.en.yml b/src/OroCRM/Bundle/MagentoBundle/Resources/translations/messages.en.yml index c7a73855650..3edabf61bf7 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Resources/translations/messages.en.yml +++ b/src/OroCRM/Bundle/MagentoBundle/Resources/translations/messages.en.yml @@ -291,6 +291,7 @@ orocrm: product_url.label: Product URL channel.label: Channel removed.label: Removed + owner.label: Owner cartstatus: entity_label: Magento Shopping Cart Status @@ -319,6 +320,7 @@ orocrm: tax_percent.label: Tax percent weight.label: Weight channel.label: Channel + owner.label: Owner magentosoaptransport: entity_label: Magento Integration Channel Transport From 5777582f858870bfd11149d3c5cc7df59c832ce6 Mon Sep 17 00:00:00 2001 From: Yurii Muratov Date: Thu, 6 Aug 2015 20:20:21 +0300 Subject: [PATCH 2/6] OEE-642: Add organization fields to the Cart and Order items - fix installer --- .../Migrations/Schema/OroCRMMagentoBundleInstaller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/OroCRMMagentoBundleInstaller.php b/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/OroCRMMagentoBundleInstaller.php index 93a1c8daa80..d479cac8d14 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/OroCRMMagentoBundleInstaller.php +++ b/src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/OroCRMMagentoBundleInstaller.php @@ -80,7 +80,7 @@ public function setVisitEventAssociationExtension(VisitEventAssociationExtension */ public function getMigrationVersion() { - return 'v1_34'; + return 'v1_35'; } /** From 6890ca4d3b45781028ff69119984a635f2f24f0d Mon Sep 17 00:00:00 2001 From: Yurii Muratov Date: Fri, 7 Aug 2015 14:36:47 +0300 Subject: [PATCH 3/6] OEE-642: Add organization fields to the Cart and Order items - fix tests --- .../DemoDataBundle/Migrations/Data/Demo/ORM/LoadMagentoData.php | 2 ++ .../Tests/Functional/Fixture/LoadMagentoChannel.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/OroCRM/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadMagentoData.php b/src/OroCRM/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadMagentoData.php index 197e8725da1..540ed72c1a5 100644 --- a/src/OroCRM/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadMagentoData.php +++ b/src/OroCRM/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadMagentoData.php @@ -312,6 +312,7 @@ protected function generateOrderItem(ObjectManager $om, Order $order, Cart $cart $orderItem->setPrice($cartItem->getPrice()); $orderItem->setOriginalPrice($cartItem->getPrice()); $orderItem->setName($cartItem->getName()); + $orderItem->setOwner($order->getOrganization()); $orderItems[] = $orderItem; $om->persist($orderItem); @@ -415,6 +416,7 @@ protected function generateShoppingCartItem(ObjectManager $om, Cart $cart) $cartItem->setUpdatedAt(new \DateTime('now')); $cartItem->setOriginId($origin); $cartItem->setCart($cart); + $cartItem->setOwner($cart->getOrganization()); $cart->getCartItems()->add($cartItem); $cart->setItemsQty($i+1); $cart->setItemsCount($i+1); diff --git a/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/Fixture/LoadMagentoChannel.php b/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/Fixture/LoadMagentoChannel.php index e66445003f3..6ca11a0cd2a 100644 --- a/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/Fixture/LoadMagentoChannel.php +++ b/src/OroCRM/Bundle/MagentoBundle/Tests/Functional/Fixture/LoadMagentoChannel.php @@ -426,6 +426,7 @@ protected function createCartItem() $cartItem->setTaxPercent(0); $cartItem->setCreatedAt(new \DateTime('now')); $cartItem->setUpdatedAt(new \DateTime('now')); + $cartItem->setOwner($this->organization); $this->em->persist($cartItem); @@ -513,6 +514,7 @@ protected function createBaseOrderItem(Order $order) $orderItem->setDiscountPercent(4); $orderItem->setDiscountAmount(0); $orderItem->setRowTotal(234); + $orderItem->setOwner($this->organization); $this->em->persist($orderItem); From b863d52e0fbc9a4d7cfd77fd8fb739c33ead877c Mon Sep 17 00:00:00 2001 From: Vova Soroka Date: Tue, 11 Aug 2015 13:29:56 +0300 Subject: [PATCH 4/6] Fix invalid form type in API controllers Conflicts: src/OroCRM/Bundle/MagentoBundle/Controller/Api/Rest/CartItemController.php --- .../AccountBundle/Controller/Api/Rest/AccountController.php | 2 +- .../Bundle/CaseBundle/Controller/Api/Rest/CommentController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OroCRM/Bundle/AccountBundle/Controller/Api/Rest/AccountController.php b/src/OroCRM/Bundle/AccountBundle/Controller/Api/Rest/AccountController.php index 46aed939804..235efc5f7c6 100644 --- a/src/OroCRM/Bundle/AccountBundle/Controller/Api/Rest/AccountController.php +++ b/src/OroCRM/Bundle/AccountBundle/Controller/Api/Rest/AccountController.php @@ -137,7 +137,7 @@ public function getManager() */ public function getForm() { - return $this->get('orocrm_account.form.type.account.api'); + return $this->get('orocrm_account.form.account.api'); } /** diff --git a/src/OroCRM/Bundle/CaseBundle/Controller/Api/Rest/CommentController.php b/src/OroCRM/Bundle/CaseBundle/Controller/Api/Rest/CommentController.php index d5c67a3b3c1..7fc4f327d5a 100644 --- a/src/OroCRM/Bundle/CaseBundle/Controller/Api/Rest/CommentController.php +++ b/src/OroCRM/Bundle/CaseBundle/Controller/Api/Rest/CommentController.php @@ -135,7 +135,7 @@ public function getManager() */ public function getForm() { - return $this->get('orocrm_case.form.type.comment.api'); + return $this->get('orocrm_case.form.comment.api'); } /** From 18b33affadbc8076cb044e95404485ea92907ef6 Mon Sep 17 00:00:00 2001 From: Michael Banin Date: Fri, 14 Aug 2015 17:07:21 +0300 Subject: [PATCH 5/6] Update changelog --- CHANGELOG.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 792240d76d7..08d8b3039c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,63 @@ +CHANGELOG for 1.7.6 +=================== +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +* 1.7.6 (2015-08-14) + * Magento order items are now organization-aware + * Fixed validation errors in REST API controller for Accounts + +CHANGELOG for 1.7.5 +=================== +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +* 1.7.5 (2015-07-29) + * Role entity is now extendable + * Data types for Data Audit may now be added by developers + * Fixed issues with date & time queries in Reports + +CHANGELOG for 1.7.4 +=================== +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +* 1.7.4 (2015-07-08) +This release fixes a major security issue - a so-called Open Redirect that might be exploited to redirect users to third-party servers in an underhand way, and may potentially lead to steal of user's login and password. +Also fixed minor security issues. + +CHANGELOG for 1.7.3 +=================== +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +* 1.7.3 (2015-07-03) +Oro Platform 1.7.3 dependency update + +CHANGELOG for 1.7.2 +=================== +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +* 1.7.2 (2015-06-17) + * Fixed issue Magento cart items during sync + * Fixed email html code visibility + +CHANGELOG for 1.7.1 +=================== +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +* 1.7.1 (2015-06-15) +Guest Magento customer profiles +With this feature we introduce a new type of Magento Customer – guest customers, i.e. those who for some reasons decided not to register in your Magento store but made a purchase anyway. Information collected during the guest check-out will be used to create Magento customer profiles that will look and behave exactly the same way as regular Magento customers except they won't be synced via integration and they won't have a current shopping cart. +If, at some later point in time, this customer chooses to register, his existing guest profile will be automatically connected to his Magento account and then kept in sync by the integration. If a customer deletes an account in Magento, the Magento customer profile in Oro will remain, but turns into a guest one. +Guest orders placed by registered customers will also be recognized and appended to their accounts, giving you the full picture of their purchases. +This feature may be disabled in Magento integration settings. It is turned on by default. + +Items removed from Magento cart will be recorded in OroCRM +Shopping carts in OroCRM will now contain the entire history of what has been put into the cart and what has been removed from it, giving you more data for marketing segmentation and campaigning. It will now be possible to set filtering conditions on item state like: + * filter all customers who do have item X in the cart + * filter all customers who have ever added item X to their carts + * filter all customers who have added but then removed item X from their carts + +List of improvements and fixed bugs + * Changed Oro Bridge detection to use soap getFunctions method + * Improved Magento Region connector + * Fixed "Create Magento Customer" is available for Organization without Magento Channel + * Fixed Delete Marketing list provokes errors + * Fixed error if add duplicate columns in Marketing list + * Fixed import B2B Customer which is related to existing Lead + * Fixed memory leak Sales Process + CHANGELOG for 1.7.0 =================== This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. From 3c48b8c0f8216bbb982352d0b41a2fa48f88c263 Mon Sep 17 00:00:00 2001 From: Michael Banin Date: Fri, 14 Aug 2015 17:09:59 +0300 Subject: [PATCH 6/6] Update changelog --- CHANGELOG.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08d8b3039c4..d791f4afbcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,13 @@ CHANGELOG for 1.7.6 =================== -This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.6 versions. * 1.7.6 (2015-08-14) * Magento order items are now organization-aware * Fixed validation errors in REST API controller for Accounts CHANGELOG for 1.7.5 =================== -This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.5 versions. * 1.7.5 (2015-07-29) * Role entity is now extendable * Data types for Data Audit may now be added by developers @@ -15,27 +15,27 @@ This changelog references the relevant changes (new features, changes and bugs) CHANGELOG for 1.7.4 =================== -This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.4 versions. * 1.7.4 (2015-07-08) This release fixes a major security issue - a so-called Open Redirect that might be exploited to redirect users to third-party servers in an underhand way, and may potentially lead to steal of user's login and password. Also fixed minor security issues. CHANGELOG for 1.7.3 =================== -This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.3 versions. * 1.7.3 (2015-07-03) Oro Platform 1.7.3 dependency update CHANGELOG for 1.7.2 =================== -This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.2 versions. * 1.7.2 (2015-06-17) * Fixed issue Magento cart items during sync * Fixed email html code visibility CHANGELOG for 1.7.1 =================== -This changelog references the relevant changes (new features, changes and bugs) done in 1.7.0 versions. +This changelog references the relevant changes (new features, changes and bugs) done in 1.7.1 versions. * 1.7.1 (2015-06-15) Guest Magento customer profiles With this feature we introduce a new type of Magento Customer – guest customers, i.e. those who for some reasons decided not to register in your Magento store but made a purchase anyway. Information collected during the guest check-out will be used to create Magento customer profiles that will look and behave exactly the same way as regular Magento customers except they won't be synced via integration and they won't have a current shopping cart.