Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dev/1.10' into 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrebenchuk committed Dec 1, 2016
2 parents aca16d0 + 6a3f9b2 commit 2f7bc57
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
'aCss': 'no-hash remove-button',
'dataId': entity.id,
'id': 'btn-remove-account',
'entity_label': 'orocrm.account.entity_label'|trans
'dataMessage': 'oro.ui.delete_confirm_cascade'|trans({
'%entity_label%' : 'orocrm.account.entity_label'|trans
}),
}) }}
{% endif %}
{% endblock navButtons %}
Expand Down
30 changes: 30 additions & 0 deletions src/OroCRM/Bundle/MagentoBundle/Datagrid/CartViewList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace OroCRM\Bundle\MagentoBundle\Datagrid;

use Oro\Bundle\DataGridBundle\Extension\GridViews\AbstractViewsList;
use Oro\Bundle\DataGridBundle\Extension\GridViews\View;
use Oro\Bundle\FilterBundle\Form\Type\Filter\NumberRangeFilterType;

class CartViewList extends AbstractViewsList
{
/**
* {@inheritdoc}
*/
protected function getViewsList()
{
return [
(new View(
'non_empty',
[
'itemsQty' => [
'type' => NumberRangeFilterType::TYPE_GREATER_THAN,
'value' => 0,
],
]
))
->setLabel($this->translator->trans('orocrm.magento.datagrid.views.non_empty_carts.label'))
->setDefault(true)
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function getRevenueOverTime(
CASE WHEN o.discountAmount IS NOT NULL THEN ABS(o.discountAmount) ELSE 0 END
) AS amount');

$dateHelper->addDatePartsSelect($from, $to, $qb, 'o.createdAt');
$dateHelper->addDatePartsSelect($from, $to, $qb, 'o.createdAt', false);

if ($to) {
$qb->andWhere($qb->expr()->between('o.createdAt', ':from', ':to'))
Expand Down
4 changes: 4 additions & 0 deletions src/OroCRM/Bundle/MagentoBundle/Resources/config/datagrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ datagrid:
type: datetime
data_name: c.updatedAt
enabled: false
itemsQty:
type: number-range
data_name: c.itemsQty
actions:
view:
type: navigate
Expand All @@ -374,6 +377,7 @@ datagrid:
entityHint: cart
export: true
entity_pagination: true
views_list : '@orocrm_magento.datagrid.cart_view_list'

magento-cartitem-grid:
extended_entity_name: OroCRM\Bundle\MagentoBundle\Entity\CartItem
Expand Down
5 changes: 5 additions & 0 deletions src/OroCRM/Bundle/MagentoBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -985,3 +985,8 @@ services:
public: false
tags:
- { name: routing.options_resolver }

orocrm_magento.datagrid.cart_view_list:
class: OroCRM\Bundle\MagentoBundle\Datagrid\CartViewList
arguments:
- '@translator'
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ orocrm:
added_to_cart: Added to cart
purchased: Purchased
datagrid:
views:
non_empty_carts.label: Magento Shopping Carts
actions:
view:
label: View
Expand Down
2 changes: 1 addition & 1 deletion src/OroCRM/Bundle/SalesBundle/Entity/B2bCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class B2bCustomer extends ExtendB2bCustomer implements
* @var Account
*
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\AccountBundle\Entity\Account", cascade="persist")
* @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="SET NULL")
* @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="CASCADE")
* @ConfigField(
* defaultValues={
* "dataaudit"={"auditable"=true},
Expand Down
2 changes: 1 addition & 1 deletion src/OroCRM/Bundle/SalesBundle/Entity/Opportunity.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class Opportunity extends ExtendOpportunity implements
* inversedBy="opportunities",
* cascade={"persist"}
* )
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id", onDelete="SET NULL")
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id", onDelete="CASCADE")
* @Oro\Versioned
* @ConfigField(
* defaultValues={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function setAttachmentExtension(AttachmentExtension $attachmentExtension)
*/
public function getMigrationVersion()
{
return 'v1_25_3';
return 'v1_25_5';
}

/**
Expand Down Expand Up @@ -520,7 +520,7 @@ protected function addOrocrmSalesOpportunityForeignKeys(Schema $schema)
$schema->getTable('orocrm_sales_b2bcustomer'),
['customer_id'],
['id'],
['onDelete' => 'SET NULL', 'onUpdate' => null]
['onDelete' => 'CASCADE', 'onUpdate' => null]
);
$table->addForeignKeyConstraint(
$schema->getTable('orocrm_channel'),
Expand Down Expand Up @@ -691,7 +691,7 @@ protected function addOrocrmSalesB2bCustomerForeignKeys(Schema $schema)
$schema->getTable('orocrm_account'),
['account_id'],
['id'],
['onDelete' => 'SET NULL', 'onUpdate' => null]
['onDelete' => 'CASCADE', 'onUpdate' => null]
);
$table->addForeignKeyConstraint(
$schema->getTable('orocrm_contact'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace OroCRM\Bundle\SalesBundle\Migrations\Schema\v1_25_5;

use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class OroCRMSalesBundle implements Migration
{
/**
* Changes account_id to onDelete=CASCADE
*
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->changeOnDeleteToCascade(
$schema,
[
'orocrm_sales_b2bcustomer' => ['account_id'],
'orocrm_sales_opportunity' => ['customer_id'],
]
);
}

/**
* @param Schema $schema
* @param array $data
* [
* table name => [column name, ...],
* ...
* ]
*/
protected function changeOnDeleteToCascade(Schema $schema, array $data)
{
foreach ($data as $tableName => $columns) {
$table = $schema->getTable($tableName);
foreach ($columns as $column) {
$foreignKeys = $table->getForeignKeys();
foreach ($foreignKeys as $foreignKey) {
$foreignKeyColumns = $foreignKey->getUnquotedLocalColumns();
if ($foreignKeyColumns === [$column]) {
if ($foreignKey->getOption('onDelete') !== 'CASCADE') {
$table->removeForeignKey($foreignKey->getName());
$table->addForeignKeyConstraint(
$foreignKey->getUnqualifiedForeignTableName(),
$foreignKeyColumns,
$foreignKey->getUnquotedForeignColumns(),
['onDelete' => 'CASCADE', 'onUpdate' => $foreignKey->getOption('onUpdate')]
);
}

break;
}
}
}
}
}
}

0 comments on commit 2f7bc57

Please sign in to comment.