-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created the Service API for the Magento_Catalog Module: * Product Attribute Media API * Product Group Price API * Tax calculation updates: * Fixed tax calculation rounding issues which appeared when a discount was applied * Fixed extra penny issue which appeared when exact tax amount ended with 0.5 cent * Fixed tax calculation issues which appeared when a customer tax rate was different from the store tax rate * Fixed price inconsistencies between catalog and shopping cart * Added support for maintaining consistent prices including tax for customers with different tax rates * Added support for applying tax rules with different priorities to be applied to subtotal only * Added support for tax rounding at individual tax rate * Porting Tax Features from Magento 1.x: * Price consistency UX and algorithm * Canadian provincial sales taxes * Fixed issues with bundle product price inconsistency across the system * Added warnings if invalid tax configuration is created in the Admin panel * Fixed issues with regards to hidden tax * Fixed bugs: * Fixed an issue where grouped price was not applied for grouped products * Fixed an issue where a fatal error occurred when opening a grouped product page without assigned products on the frontend * Fixed an issue where it was possible to apply an inactive discount coupon * Fixed an issue where the linked products information was lost when exporting products * Fixed non-informative error messages for "Attribute Group Service" * Fixed the invalid default value of the "apply_after_discount" tax setting * Fixed an issue where the integration tests coverage whitelist was broken * Fixed Admin panel UI issues: grids, headers and footers * Added the following functional tests: * Create Product Url Rewrite * Delete Catalog Price Rule * Delete Category Url Rewrite * Delete CMS Page Rewrite * Delete Product Rating * Delete Sales Rule * Delete Tax Rate * Update Catalog Price Rule * Update Shopping Cart
- Loading branch information
1 parent
658b76f
commit ea1a2b7
Showing
185 changed files
with
9,604 additions
and
693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
app/code/Magento/Catalog/Model/Product/PriceModifier.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
/** | ||
* Magento | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@magentocommerce.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Magento to newer | ||
* versions in the future. If you wish to customize Magento for your | ||
* needs please refer to http://www.magentocommerce.com for more information. | ||
* | ||
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
namespace Magento\Catalog\Model\Product; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Framework\Exception\CouldNotSaveException; | ||
|
||
class PriceModifier | ||
{ | ||
/** | ||
* @param \Magento\Catalog\Model\Product $product | ||
* @param int $customerGroupId | ||
* @param int $websiteId | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
* @throws \Magento\Framework\Exception\CouldNotSaveException | ||
* @return void | ||
*/ | ||
public function removeGroupPrice(\Magento\Catalog\Model\Product $product, $customerGroupId, $websiteId) | ||
{ | ||
$prices = $product->getData('group_price'); | ||
if (is_null($prices)) { | ||
throw new NoSuchEntityException("This product doesn't have group price"); | ||
} | ||
$groupPriceQty = count($prices); | ||
|
||
foreach ($prices as $key => $groupPrice) { | ||
if ($groupPrice['cust_group'] == $customerGroupId | ||
&& intval($groupPrice['website_id']) === intval($websiteId)) { | ||
unset ($prices[$key]); | ||
} | ||
} | ||
if ($groupPriceQty == count($prices)) { | ||
throw new NoSuchEntityException( | ||
"Product hasn't group price with such data: customerGroupId = '$customerGroupId'," | ||
. "website = $websiteId." | ||
); | ||
} | ||
$product->setData('group_price', $prices); | ||
try { | ||
$product->save(); | ||
} catch (\Exception $exception) { | ||
throw new CouldNotSaveException("Invalid data provided for group price"); | ||
} | ||
} | ||
|
||
/** | ||
* @param \Magento\Catalog\Model\Product $product | ||
* @param int|string $customerGroupId | ||
* @param int $qty | ||
* @param int $websiteId | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
* @throws \Magento\Framework\Exception\CouldNotSaveException | ||
* @return void | ||
*/ | ||
public function removeTierPrice(\Magento\Catalog\Model\Product $product, $customerGroupId, $qty, $websiteId) | ||
{ | ||
$prices = $product->getData('tier_price'); | ||
// verify if price exist | ||
if (is_null($prices)) { | ||
throw new NoSuchEntityException("This product doesn't have tier price"); | ||
} | ||
$tierPricesQty = count($prices); | ||
|
||
foreach ($prices as $key => $tierPrice) { | ||
if ($customerGroupId == 'all' && $tierPrice['price_qty'] == $qty | ||
&& $tierPrice['all_groups'] == 1 && intval($tierPrice['website_id']) === intval($websiteId)) { | ||
unset ($prices[$key]); | ||
} elseif ($tierPrice['price_qty'] == $qty && $tierPrice['cust_group'] == $customerGroupId | ||
&& intval($tierPrice['website_id']) === intval($websiteId)) { | ||
unset ($prices[$key]); | ||
} | ||
} | ||
|
||
if ($tierPricesQty == count($prices)) { | ||
throw new NoSuchEntityException( | ||
"Product hasn't group price with such data: customerGroupId = '$customerGroupId'," | ||
. "website = $websiteId, qty = $qty" | ||
); | ||
} | ||
$product->setData('tier_price', $prices); | ||
try { | ||
$product->save(); | ||
} catch (\Exception $exception) { | ||
throw new CouldNotSaveException("Invalid data provided for tier_price"); | ||
} | ||
} | ||
} |
Oops, something went wrong.