Skip to content
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

Product Feed: Add attribute mapping #838

Merged
merged 4 commits into from
Aug 3, 2023
Merged

Conversation

krzysztofwolski
Copy link
Member

@krzysztofwolski krzysztofwolski commented Aug 2, 2023

Scope of the PR

Google feed has specialized fields for the attributes (Size, Color, etc). This change adds configuration for choosing the right attributes:

image

Which is later used for the feed generation:

<item>
<g:id>118223581</g:id>
<title>Paul's Balance 420 - 39</title>
<g:condition>new</g:condition>
<g:availability>in_stock</g:availability>
<g:product_type>Sneakers</g:product_type>
<g:description>Step into summer with the right balance.&nbsp;Every time your head goes down, you see these beauties, and your mood bounces right back up.</g:description>
<link>http://example.com</link>
<g:image_link>https://kot.eu.saleor.cloud/media/thumbnails/products/saleor-pauls-blanace-420-1_thumbnail_256.png</g:image_link>
<g:price>50.00 USD</g:price>
<g:size>39</g:size>  // mapped from product attributes
</item>
<item>
<g:id>124223581</g:id>
<title>Own your stack and data - iTunes</title>
<g:condition>new</g:condition>
<g:availability>in_stock</g:availability>
<g:product_type>Audiobooks</g:product_type>
<g:description>Own your investment, ditch vendor lock-in</g:description>
<link>http://example.com</link>
<g:image_link>https://kot.eu.saleor.cloud/media/thumbnails/products/saleor-own-your-stack-and-data-book_thumbnail_256.png</g:image_link>
<g:price>1.20 USD</g:price>
<g:material>iTunes</g:material>  // mapped from product attributes
<g:brand>Saleor Publishing</g:brand>  // mapped from product attributes
</item>

I've ditched the idea of keeping mapping in the metadata due to:

  • it would require additional permission for the app (manage Attributes)
  • some attributes like size, might be required in particular order defined by user (eg height/width). Keeping id mapping in the App metadata gives us this feature (keeping order distributed across the attributes would be more complicated)

Related issues

Related: #814

Checklist

@krzysztofwolski krzysztofwolski self-assigned this Aug 2, 2023
@changeset-bot
Copy link

changeset-bot bot commented Aug 2, 2023

🦋 Changeset detected

Latest commit: 064b649

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
saleor-app-products-feed Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Aug 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
saleor-app-products-feed ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 2, 2023 4:21pm
9 Ignored Deployments
Name Status Preview Comments Updated (UTC)
saleor-app-cms-v2 ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2023 4:21pm
saleor-app-crm ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2023 4:21pm
saleor-app-data-importer ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2023 4:21pm
saleor-app-emails-and-messages ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2023 4:21pm
saleor-app-invoices ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2023 4:21pm
saleor-app-klaviyo ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2023 4:21pm
saleor-app-search ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2023 4:21pm
saleor-app-slack ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2023 4:21pm
saleor-app-taxes ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2023 4:21pm

"saleor-app-products-feed": minor
---

Added new feature: Attributes required by the Google Merchant can now be mapped to product attributes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can have a better message. No need to write "new feature" - this is followed by "minor"

Instead, please describe which exactly attributes are added.

.query(async ({ ctx: { logger, apiClient } }) => {
const fetcher = new AttributeFetcher(apiClient);

const result = await fetcher.fetchAllAttributes().catch((e) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log error here and it should go to sentry

FetchAttributesWithMappingDocument,
} from "../../../generated/graphql";

export class AttributeFetcher {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice implementation, maybe we can make it generic and put to shared

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lkostrowski well, thats copy of your implementation of the Caregory fetcher 😃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

@krzysztofwolski
Copy link
Member Author

@lkostrowski applied CRs. Spotted one missing attribute and added it.

@krzysztofwolski krzysztofwolski merged commit aece073 into main Aug 3, 2023
5 checks passed
@krzysztofwolski krzysztofwolski deleted the pf-attribute-matching branch August 3, 2023 08:27
Tha-Toe pushed a commit to Flo3Digital/saleor-apps that referenced this pull request Aug 10, 2023
* Add attribute mapping

* Improve release note

* Log the error

* Add pattern attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants