Skip to content

Commit

Permalink
Merge pull request #540 from magento-tango/MAGETWO-51859
Browse files Browse the repository at this point in the history
[Tango] Bugfixes
  • Loading branch information
Bomko, Alex(abomko) committed Apr 14, 2016
2 parents 072a1ae + de3ce5c commit f93b8da
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,8 @@ public function providerForGetterTierPriceList()
'basePrice' => 20.,
'expectedResult' => [
[
'price' => '50.',
'website_price' => '50.',
'price_qty' => '2.',
'cust_group' => Group::CUST_GROUP_ALL,
],
[
'price' => '30.',
'website_price' => '30.',
'price' => '15.',
'website_price' => '15.',
'price_qty' => '5.',
'cust_group' => Group::CUST_GROUP_ALL
],
Expand Down
7 changes: 6 additions & 1 deletion app/code/Magento/Catalog/Pricing/Price/TierPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ protected function filterTierPrices(array $priceList)
$qtyCache = [];
$allCustomersGroupId = $this->groupManagement->getAllCustomersGroup()->getId();
foreach ($priceList as $priceKey => &$price) {
if ($price['price'] >= $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue()) {
unset($priceList[$priceKey]);
continue;
}

if (isset($price['price_qty']) && $price['price_qty'] == 1) {
unset($priceList[$priceKey]);
continue;
Expand Down Expand Up @@ -204,7 +209,7 @@ protected function getBasePrice()
public function getSavePercent(AmountInterface $amount)
{
return ceil(
100 - ((100 / $this->priceInfo->getPrice(RegularPrice::PRICE_CODE)->getAmount()->getBaseAmount())
100 - ((100 / $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue())
* $amount->getBaseAmount())
);
}
Expand Down
26 changes: 12 additions & 14 deletions app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

namespace Magento\Catalog\Test\Unit\Pricing\Price;

use \Magento\Catalog\Pricing\Price\TierPrice;
use \Magento\Catalog\Pricing\Price\RegularPrice;

use Magento\Catalog\Pricing\Price\TierPrice;
use Magento\Catalog\Pricing\Price\FinalPrice;
use Magento\Customer\Model\Group;
use Magento\Customer\Model\GroupManagement;

Expand Down Expand Up @@ -271,6 +270,10 @@ public function testGetterTierPriceList($tierPrices, $basePrice, $expectedResult
$this->calculator->expects($this->atLeastOnce())->method('getAmount')
->will($this->returnArgument(0));

$this->priceInfo->expects(static::atLeastOnce())
->method('getPrice')
->with(FinalPrice::PRICE_CODE)
->willReturn($price);
$this->priceCurrencyMock->expects($this->any())
->method('convertAndRound')
->will($this->returnCallback(
Expand Down Expand Up @@ -365,20 +368,15 @@ public function providerForGetterTierPriceList()
*/
public function testGetSavePercent($basePrice, $tierPrice, $savedPercent)
{
$priceAmount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface');
$priceAmount->expects($this->once())
->method('getBaseAmount')
->will($this->returnValue($basePrice));

$price = $this->getMock('Magento\Framework\Pricing\Price\PriceInterface');
$price->expects($this->any())
->method('getAmount')
->will($this->returnValue($priceAmount));

$this->priceInfo->expects($this->atLeastOnce())
$this->priceInfo->expects(static::atLeastOnce())
->method('getPrice')
->will($this->returnValue($price))
->with(RegularPrice::PRICE_CODE);
->with(FinalPrice::PRICE_CODE)
->willReturn($price);
$price->expects(static::atLeastOnce())
->method('getValue')
->willReturn($basePrice);

$amount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface');
$amount->expects($this->atLeastOnce())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ protected function customizeNameListeners(array $meta)
'handleShortDescriptionChanges' => '${$.provider}:data.product.short_description',
'handleSizeChanges' => '${$.provider}:data.product.size'
],
'allowImport' => !$this->locator->getProduct()->getId(),
];

if (!in_array($listener, $textListeners)) {
Expand All @@ -356,8 +357,7 @@ protected function customizeNameListeners(array $meta)
$skuPath . static::META_CONFIG_PATH,
$meta,
[
'autoImportIfEmpty' => true,
'allowImport' => $this->locator->getProduct()->getId() ? false : true,
'autoImportIfEmpty' => true
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,10 @@ protected function getRows()
'elementTmpl' => 'Magento_ConfigurableProduct/components/file-uploader',
'fileInputName' => 'image',
'isMultipleFiles' => false,
'imports' => [
'links' => [
'thumbnailUrl' => '${$.provider}:${$.parentScope}.thumbnail_image',
'thumbnail' => '${$.provider}:${$.parentScope}.thumbnail'
'thumbnail' => '${$.provider}:${$.parentScope}.thumbnail',
'smallImage' => '${$.provider}:${$.parentScope}.small_image',
],
'uploaderConfig' => [
'url' => $this->urlBuilder->addSessionParam()->getUrl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define([
actionsListOpened: false,
thumbnailUrl: '',
thumbnail: null,
smallImage: null,
defaults: {
fileInputName: ''
},
Expand All @@ -23,7 +24,7 @@ define([
* @returns {Object} Chainable.
*/
initObservable: function () {
this._super().observe(['processedFile', 'actionsListOpened', 'thumbnailUrl', 'thumbnail']);
this._super().observe(['processedFile', 'actionsListOpened', 'thumbnailUrl', 'thumbnail', 'smallImage']);

return this;
},
Expand Down Expand Up @@ -89,6 +90,9 @@ define([
deleteImage: function () {
this.processedFile({});
this.value(null);
this.thumbnail(null);
this.thumbnailUrl(null);
this.smallImage(null);

return this;
}
Expand Down

0 comments on commit f93b8da

Please sign in to comment.