-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Pull - Expose Attribute mapping Rules Values #2351
API Pull - Expose Attribute mapping Rules Values #2351
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/google-api-project #2351 +/- ##
==============================================================
+ Coverage 64.2% 64.5% +0.3%
- Complexity 4478 4521 +43
==============================================================
Files 471 471
Lines 18853 18958 +105
==============================================================
+ Hits 12110 12233 +123
+ Misses 6743 6725 -18
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I see we keep all the current code in WCAdapter as well and we just duplicate the code. Not sure if we can reuse the functions to avoid duplication. Also, what about the rest of the filters and overrides in WC Product adapter? Are they not necessary? |
Hi @puntope, thanks for taking a look
Initially, I considered updating the WCAdapter to use the methods in AttributeManager to avoid duplicated code. However, I'm unsure if it's worthwhile to refactor this part since it will likely become obsolete as we are not pushing the attributes and the product data anymore in the following stages. We could simply remove the attribute part from WCAdapter, or even the entire class.
Can you point me to the other filters not included in the AttributeManager? |
That's what I mean. Right now all some methods are duplicated between |
All the methods that are not related to Attribute Mapping. For example the |
@puntope, thanks for the clarification.
Yes, but it is also too early to remove the methods in
|
Actually, we can't use the same filter |
Thanks @jorgemd24 for all the explanations. What I don't fully understand is why migrate now all the code to AttributeManager instead of keeping it in WCProductAdapter, as far as I get we:
As far as I read, the advantage is to not create an instance of WCProductAdapter. Not sure how critical this is and how it would be affecting the code. |
Hey @puntope. I aimed to make the attributes separate from the Anyway, I've put together an alternative PR that uses the |
closing this PR in favor of #2366. |
Changes proposed in this Pull Request:
Part of #2146
As we move to a new approach for fetching products using the WC REST API, we need to make product's attribute mapping values accessible. Hence, this PR introduces a new property to the
wc/v3/products
endpoint, namedgla_attributes
. This property will contain the attribute values after applying all GLA Mapping Attribute rules, with GLA attributes taking precedence over mapping rules.Also, I realized that most of the logic for mapping attribute rules resides within
WCProductAdapter
. In my view, moving this logic to theAttributeManager
class would be more logical, given its existing handling of GLA attributes. Therefore, I've moved and adjusted most of the logic from theWCProductAdapter
to theAttributeManager
class. This adjustment will enable us to independently retrieve attributes from a product, without needing to create an instance ofWCProductAdapter
.I was thinking of refactoring
WCProductAdapter
to use the new methods in theAttributeManager
class, however, as we are not going to sync the attributes anymore I believe it's unnecessary to refactor that section as we will delete that part of the code in the next stages.Screenshots:
Detailed test instructions:
GET wc/v3/products?gla_syncable=1
orGET wc/v3/products/YOUR_PRODUCT_ID?gla_syncable=1
gla_attributes
with the correct values.gla_syncable=1
and the response should not containgla_attributes
.Additional details:
Changelog entry