adobe / commerce-cif-connector

AEM Commerce connector for Magento and GraphQL
Apache License 2.0
43 stars 27 forks source link

CIF-1182 - replace component jsp to use produt sku for d&d #103

Closed mhaack closed 4 years ago

mhaack commented 4 years ago

Description

The "output" of product picker and asset finder d&d is different, the picker is mostly used to return SKU, while asset finder d&d returned full virtual product path. This must be unified and asset finder should return SKU as well.

Related Issue

CIF-1182

How Has This Been Tested?

Manually

Types of changes

Checklist:

cjelger commented 4 years ago

Hmmm, I don't really agree with that change, mainly because the picker can be configured by each component to either save the path, sku, slug, or combinedSku. I hence rather think that the D'n'D should save exactly the same identifier as being configured in the picker. I know it's more complicated, but it would ensure that if anyone configures the picker of some component to save the slug, the D'n'D would do the same.

mhaack commented 4 years ago

@cjelger that is a good point and I initially was thinking in the same direction. The challenge is the asset finder is not customizable and aware of the d&d target. There can be different components using the product field & product picker with different identifiers. Component one might use sku while component two uses slug the asset finder does not know about this.

cjelger commented 4 years ago

Yes, that's why @LSantha proposed to do it in a similar way than CIF-1115, where we should detect that a property is being saved by D'n'D, find the picker config for the component, and then save the right property. It's clearly more complicated, but is probably feasible. I think the main challenge is to properly detect that a property is being set via D'n'D so we only "manipulate" the value in this particular case.

codecov[bot] commented 4 years ago

Codecov Report

Merging #103 into master will decrease coverage by 0.31%. The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #103      +/-   ##
============================================
- Coverage     87.54%   87.23%   -0.32%     
  Complexity      394      394              
============================================
  Files            29       29              
  Lines          1582     1582              
  Branches        227      227              
============================================
- Hits           1385     1380       -5     
- Misses           93       98       +5     
  Partials        104      104
Flag Coverage Δ Complexity Δ
#integration 54.78% <ø> (ø) 241 <ø> (ø) :arrow_down:
#karma 92.71% <ø> (-3.32%) 0 <ø> (ø)
#unittests 82.73% <ø> (ø) 377 <ø> (ø) :arrow_down:
Impacted Files Coverage Δ Complexity Δ
...omponents/common/cifpicker/clientlibs/cifpicker.js 80% <0%> (-11.12%) 0% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9c72f17...726a4e5. Read the comment docs.

mhaack commented 4 years ago

I don't really like this magical detection and tweaking things under the hood. Instead, I vote for more simplification, there is no need for path, sku, slug, or combinedSku options and one method to identify products would be enough - for this kind of authorizable components. I suggest we reduce this to sku / combined sku.

mhaack commented 4 years ago

Also a detection and change to the right property will not help here for all cases. The default product.jsp returns the virtual path which includes the sku. Hence we could detect if sku is the desired property of the component. But we can not get the slug from the path, this would require some additional product query.

LSantha commented 4 years ago

Actually we could pass a new parameter similar to selectionId in the pickers where we can specify what to provide as identifier for the card item used in DnD. The parameter can be passed here: https://github.com/adobe/commerce-cif-connector/blob/master/content/cif-virtual-catalog/src/main/content/jcr_root/libs/commerce/gui/components/authoring/assetfinder/product/clientlibs/ProductAssetPanel.js#L36