Skip to content
Permalink
Browse files

SW-20659 - Optimize basket performance

  • Loading branch information...
htkassner committed Dec 4, 2017
1 parent e588357 commit 0ad61b3e30aeab2a50c348f613dba7a8aed18d85
@@ -12,13 +12,29 @@ This changelog references changes done in Shopware 5.5 patch versions.
- `IFrameComponentHandler`
- `YoutubeComponentHandler`
* Added `mainDetail` to REST API call for retrieving a list of products
* Added struct `Shopware\Components\Cart\Struct\CartItemStruct` to represent items in the cart during calculation
* Added public function `sBasket::updateCartItems` to provide a new way of interacting with cart updates
* Added following templates to `themes/Frontend/Bare/frontend/checkout/`
* `cart_item_premium_product.tpl`
* `cart_item_product.tpl`
* `cart_item_rebate.tpl`
* `cart_item_surcharge_discount.tpl`
* `cart_item_voucher.tpl`

### Changes

* Changed the execution model of `replace` hooks to prevent multiple calls of the hooked method, if more than one `replace` hook on the same method exists and all of them call `executeParent()` once
* Changed Symfony version to 3.4.4
* Changed the event `Shopware_Form_Builder` so that the `reference` contains the `BlockPrefix` of the Formtype, not the name
* Changed REST API `articles` list call to include `mainDetail`
* Changed REST API `articles` list call to include `mainDetail`
* Changed `themes/Frontend/Bare/frontend/checkout/cart_item.tpl` in which the following blocks are contained:
* `frontend_checkout_cart_item_product`
* `frontend_checkout_cart_item_premium_product`
* `frontend_checkout_cart_item_voucher`
* `frontend_checkout_cart_item_rebate`
* `frontend_checkout_cart_item_surcharge_discount`

All these blocks are moved to own template files to optimize include process.

### Removals

@@ -0,0 +1,175 @@
<?php
/**
* Shopware 5
* Copyright (c) shopware AG
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Shopware" is a registered trademark of shopware AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
namespace Shopware\Components\Cart\Struct;
class CartItemStruct
{
/**
* @var int
*/
private $id;
/**
* @var int
*/
private $quantity;
/**
* @var array
*/
private $additionalInfo;
/**
* @var array
*/
private $updatedPrice;
/**
* @var float
*/
private $taxRate;
/**
* @var float
*/
private $netPrice;
/**
* @var float
*/
private $grossPrice;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id = null)
{
$this->id = $id;
}
/**
* @return int
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* @param int $quantity
*/
public function setQuantity($quantity = 0)
{
$this->quantity = $quantity;
}
/**
* @return array
*/
public function getAdditionalInfo()
{
return $this->additionalInfo;
}
/**
* @param array $additionalInfo
*/
public function setAdditionalInfo($additionalInfo)
{
$this->additionalInfo = $additionalInfo;
}
/**
* @return array
*/
public function getUpdatedPrice()
{
return $this->updatedPrice;
}
/**
* @param array $updatedPrice
*/
public function setUpdatedPrice(array $updatedPrice)
{
$this->updatedPrice = $updatedPrice;
}
/**
* @return float
*/
public function getTaxRate()
{
return $this->taxRate;
}
/**
* @param float $taxRate
*/
public function setTaxRate($taxRate)
{
$this->taxRate = $taxRate;
}
/**
* @return float
*/
public function getNetPrice()
{
return $this->netPrice;
}
/**
* @param float $netPrice
*/
public function setNetPrice($netPrice)
{
$this->netPrice = $netPrice;
}
/**
* @return float
*/
public function getGrossPrice()
{
return $this->grossPrice;
}
/**
* @param float $grossPrice
*/
public function setGrossPrice($grossPrice)
{
$this->grossPrice = $grossPrice;
}
}
@@ -977,8 +977,6 @@ public function getShippingCosts()
*/
public function getBasket()
{
$this->updateArticles();
$shippingcosts = $this->getShippingCosts();
$basket = $this->basket->sGetBasket();
@@ -1897,24 +1895,6 @@ private function areAddressesEqual(array $addressA, array $addressB)
return count(array_diff($addressA, $addressB)) === 0;
}
/**
* Updates all articles in the basket
*/
private function updateArticles()
{
$query = $this->container->get('dbal_connection')->createQueryBuilder();
$query->select(['id', 'quantity']);
$query->from('s_order_basket', 'basket');
$query->where('basket.modus = 0');
$query->andWhere('basket.sessionID = :sessionId');
$query->setParameter(':sessionId', Shopware()->Session()->get('sessionId'));
$articles = $query->execute()->fetchAll(PDO::FETCH_KEY_PAIR);
foreach ($articles as $id => $quantity) {
$this->basket->sUpdateArticle($id, $quantity);
}
}
/**
* @return string
*/

1 comment on commit 0ad61b3

@JoshuaBehrens

This comment has been minimized.

Copy link
Contributor

commented on 0ad61b3 Apr 10, 2018

positive reaction

Please sign in to comment.
You can’t perform that action at this time.