magento2
magento2 copied to clipboard
Fixed Product Taxes (FPT) are not used from simple products
Good afternoon,
This is a step from a concrete pull request. All the credits go to @kanduvisla, author of this patch.
Issue :
We were missing the Fixed Product Taxes (a.k.a FPT) in the product infos, checkout cart and checkout processing for configurable products. Please note with this PR the FPT is still not displaying in the product info page which can disturb customers.
Related Pull Requests
Resolve the issue described in : #4774 #25554 #28931
Manual testing scenarios (*)
Enable FPT - Stores - sales -tax- Enable fixed product tax Create a new attribute (code: dynamic_weight_rate / type: fixed product tax) Create a new "attribute set" and assign an attribute to it Assign attribute set to a configurable product (previously created or a new one) Update FPT information on each simple product related to configurable one On front-office, try to add a configurable product to the cart No FPT row on summary cart, cart and checkout process is added.
Questions or comments
Problems of the current implentation of this code :
This current code use around plugin and load one simple product from each configurable products which can harms the performance.
Not particulary at ease with the current implentation as the others products type (Pricing models, etc.) implentation but I wanna particulary goes up this issue to the community and Magento teams whose has closed issues.
Hi @Amadeco. Thank you for your contribution Here are some useful tips how you can test your changes using Magento test environment. Add the comment under your pull request to deploy test or vanilla Magento instance:
-
@magento give me test instance
- deploy test instance based on PR changes -
@magento give me 2.4-develop instance
- deploy vanilla Magento instance
:exclamation: Automated tests can be triggered manually with an appropriate comment:
-
@magento run all tests
- run or re-run all required tests against the PR changes -
@magento run <test-build(s)>
- run or re-run specific test build(s) For example:@magento run Unit Tests
<test-build(s)>
is a comma-separated list of build names. Allowed build names are:
-
Database Compare
-
Functional Tests CE
-
Functional Tests EE
, -
Functional Tests B2B
-
Integration Tests
-
Magento Health Index
-
Sample Data Tests CE
-
Sample Data Tests EE
-
Sample Data Tests B2B
-
Static Tests
-
Unit Tests
-
WebAPI Tests
-
Semantic Version Checker
You can find more information about the builds here
:information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.
For more details, review the Magento Contributor Guide documentation.
:warning: According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
@magento run all tests
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.
I think I found a better solution for this. Just apply this patch for magento/module-weee
module and it will combine both FPTs (if configurable FPT isset) with simple FPT value (if isset)
--- a/Model/Tax.php
+++ b/Model/Tax.php
@@ -6,6 +6,7 @@
namespace Magento\Weee\Model;
use Magento\Catalog\Model\Product;
+use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Store\Model\Website;
use Magento\Tax\Model\Calculation;
@@ -310,6 +311,17 @@
$product->getId()
);
+ if ($product->getTypeId() === Configurable::TYPE_CODE) {
+ $simpleAttributes = $this->getResource()->fetchWeeeTaxCalculationsByEntity(
+ $rateRequest->getCountryId(),
+ $rateRequest->getRegionId(),
+ $websiteId,
+ $store->getId(),
+ $product->getCustomOption('simple_product')->getValue()
+ );
+ $productAttributes = array_merge($productAttributes, $simpleAttributes);
+ }
+
foreach ($productAttributes as $attribute) {
$value = $attribute['weee_value'];
if ($value) {