Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into MAGETWO-44448-va…
Browse files Browse the repository at this point in the history
…rnish-bottle-neck
  • Loading branch information
Joan He committed Nov 2, 2015
2 parents 968cf7d + fc7a956 commit 9d93e76
Show file tree
Hide file tree
Showing 19 changed files with 430 additions and 45 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/Braintree/Model/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,8 @@ protected function processSuccessResult(
*/
public function canVoid()
{
if (($order = $this->_registry->registry('current_order'))
&& $order->getId() && $order->hasInvoices() ) {
if ((($order = $this->_registry->registry('current_order'))
&& $order->getId() && $order->hasInvoices()) || $this->_registry->registry('current_invoice')) {
return false;
}
return $this->_canVoid;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model\ResourceModel;

use Magento\Framework\App\ResourceConnection;

class MaxHeapTableSizeProcessor
{
/**
* Database connection adapter
*
* @var \Magento\Framework\DB\Adapter\AdapterInterface
*/
protected $connection;

/**
* @var int
*/
protected $defaultMaxHeapTableSie;

/**
* Current max_heap_table_size value (in Bytes)
*
* @var int
*/
protected $currentMaxHeapTableSize = null;

/**
* @param ResourceConnection $resource
*/
public function __construct(ResourceConnection $resource)
{
$this->connection = $resource->getConnection();
$this->defaultMaxHeapTableSie = 1024 * 1024 * 64;
}

/**
* Set max_heap_table_size value in Bytes. By default value is 64M
*
* @param int|null $maxHeapTableSize
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @return void
*/
public function set($maxHeapTableSize = null)
{
$maxHeapTableSize = (int) (null === $maxHeapTableSize ? $this->defaultMaxHeapTableSie : $maxHeapTableSize);
if (!$maxHeapTableSize) {
throw new \InvalidArgumentException('Wrong max_heap_table_size parameter');
}

$this->currentMaxHeapTableSize = (int)$this->connection->fetchOne('SELECT @@session.max_heap_table_size');
if (!$this->currentMaxHeapTableSize) {
throw new \RuntimeException('Can not extract max_heap_table_size');
}

$this->connection->query('SET SESSION max_heap_table_size = ' . $maxHeapTableSize);
}

/**
* Restore max_heap_table_size value
*
* @throws \RuntimeException
* @return void
*/
public function restore()
{
if (null === $this->currentMaxHeapTableSize) {
throw new \RuntimeException('max_heap_table_size parameter is not set');
}
$this->connection->query('SET SESSION max_heap_table_size = ' . $this->currentMaxHeapTableSize);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Plugin\Model\Indexer\Category\Product;

use Magento\Catalog\Model\Indexer\Category\Product\Action\Full;
use Magento\Catalog\Model\ResourceModel\MaxHeapTableSizeProcessor;
use Psr\Log\LoggerInterface;

class MaxHeapTableSizeProcessorOnFullReindex
{
/**
* @var MaxHeapTableSizeProcessor
*/
protected $maxHeapTableSizeProcessor;

/**
* @param MaxHeapTableSizeProcessor $maxHeapTableSizeProcessor
* @param LoggerInterface $logger
*/
public function __construct(
MaxHeapTableSizeProcessor $maxHeapTableSizeProcessor,
LoggerInterface $logger
) {
$this->maxHeapTableSizeProcessor = $maxHeapTableSizeProcessor;
$this->logger = $logger;
}

/**
* @param Full $subject
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeExecute(Full $subject)
{
try {
$this->maxHeapTableSizeProcessor->set();
} catch (\Exception $e) {
$this->logger->error($e);
}
}

/**
* @param Full $subject
* @param Full $result
* @return Full
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterExecute(Full $subject, Full $result)
{
try {
$this->maxHeapTableSizeProcessor->restore();
} catch (\Exception $e) {
$this->logger->error($e);
}
return $result;
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
</type>
<type name="Magento\Catalog\Model\Indexer\Category\Product\Action\Full">
<plugin name="invalidate_pagecache_after_full_reindex" type="Magento\Catalog\Plugin\Model\Indexer\Category\Product\Execute" />
<plugin name="max_heap_tablse_size_processor_on_full_reindex" type="Magento\Catalog\Plugin\Model\Indexer\Category\Product\MaxHeapTableSizeProcessorOnFullReindex"/>
</type>
<type name="Magento\Catalog\Model\ResourceModel\Attribute">
<plugin name="invalidate_pagecache_after_attribute_save" type="Magento\Catalog\Plugin\Model\ResourceModel\Attribute\Save" />
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/CustomerImportExport/etc/import.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
<entity name="customer_composite" label="Customers and Addresses (single file)" model="Magento\CustomerImportExport\Model\Import\CustomerComposite" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Basic" />
<entity name="customer" label="Customers Main File" model="Magento\CustomerImportExport\Model\Import\Customer" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Custom" />
<entity name="customer_address" label="Customer Addresses" model="Magento\CustomerImportExport\Model\Import\Address" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Custom" />
<relatedIndexer entity="customer" name="customer_grid" />
<relatedIndexer entity="customer_address" name="customer_grid" />
<relatedIndexer entity="customer_composite" name="customer_grid" />
</config>
2 changes: 2 additions & 0 deletions app/code/Magento/ImportExport/Files/Sample/customer.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
email,_website,_store,confirmation,created_at,created_in,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,reward_update_notification,reward_warning_notification,rp_token,rp_token_created_at,store_id,suffix,taxvat,updated_at,website_id,password
jondoe@example.com,base,default,,"2015-10-30 12:49:47","Default Store View",0,,Jon,,1,Doe,,d708be3fe0fe0120840e8b13c8faae97424252c6374227ff59c05814f1aecd79:mgLqkqgTwLPLlCljzvF8hp67fNOOvOZb:1,,,,07e71459c137f4da15292134ff459cba,"2015-10-30 12:49:48",1,,,"2015-10-30 12:49:48",1,
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_website,_email,_entity_id,city,company,country_id,fax,firstname,lastname,middlename,postcode,prefix,region,region_id,street,suffix,telephone,vat_id,vat_is_valid,vat_request_date,vat_request_id,vat_request_success,_address_default_billing_,_address_default_shipping_
base,jondoe@example.com,1,"New York",,US,,Jon,Doe,,10044,,"New York",43,"Main Street 1",,123456789,,,,,,1,1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_email,_website,_finance_website,store_credit,reward_points
jondoe@example.com,base,base,10.0000,100
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
protected $_idAttributes = [
'/config/entity' => 'name',
'/config/entityType' => ['entity', 'name'],
'/config/relatedIndexers' => ['entity', 'name'],
'/config/relatedIndexer' => ['entity', 'name'],
];

/**
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ public function collect(
$total->setBaseTotalAmount($this->getCode(), $rate->getPrice());
$shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
$address->setShippingDescription(trim($shippingDescription, ' -'));
$total->setShippingAmount($rate->getPrice());
$total->setShippingDescription($address->getShippingDescription());
break;
}
}
Expand All @@ -184,6 +186,7 @@ public function collect(
* @param \Magento\Quote\Model\Quote $quote
* @param \Magento\Quote\Model\Quote\Address\Total $total
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
{
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Quote/Model/Quote/TotalsCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public function collect(\Magento\Quote\Model\Quote $quote)
foreach ($quote->getAllAddresses() as $address) {
$addressTotal = $this->collectAddressTotals($quote, $address);

$total->setShippingAmount($addressTotal->getShippingAmount());
$total->setBaseShippingAmount($addressTotal->getBaseShippingAmount());
$total->setShippingDescription($addressTotal->getShippingDescription());

$total->setSubtotal((float)$total->getSubtotal() + $addressTotal->getSubtotal());
$total->setBaseSubtotal((float)$total->getBaseSubtotal() + $addressTotal->getBaseSubtotal());

Expand Down
Loading

0 comments on commit 9d93e76

Please sign in to comment.