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

ISSUE-2223: Fixed the bug with breadcrumbs on PDP with a product without categories #2224

Merged
merged 2 commits into from
Mar 12, 2020

Conversation

andrewbess
Copy link

Description

This PR fixes the bug with breadcrumbs on PDP when a product isn't assigned anything category

Related Issue

Closes #2223.

Acceptance

Verification Stakeholders

Specification

Verification Steps

  1. Go to the admin panel in backend instance;
  2. Go to the product grid and select any product to edit;
  3. Unassign the categories from the product and save a product;
  4. Run reindex;
  5. Copy the product link using URL-Key;
  6. Try to view the product by link;
  7. Verify the error doesn't reproduce.

Screenshots / Screen Captures (if appropriate)

error-on-console

@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Mar 6, 2020

Fails
🚫 A version label is required. A maintainer must add one.
Messages
📖

Access a deployed version of this PR here. Make sure to wait for the "pwa-pull-request-deploy" job to complete.

📖 DangerCI Failures related to missing labels/description/linked issues/etc will persist until the next push or next nightly build run (assuming they are fixed).

Generated by 🚫 dangerJS against 7a508fd

Copy link
Contributor

@sirugh sirugh left a comment

Choose a reason for hiding this comment

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

Thanks for opening this PR! This definitely solves the case for when there are no categories for a product, especially since it was previously just throwing an error.

Please make the minor change to the conditional and add a comment above it as suggested.

Cheers!

@@ -97,6 +97,9 @@ const getMediaGalleryEntries = (product, optionCodes, optionSelections) => {
// product has multiple related categories. This function filters and selects
// one category id for that purpose.
const getBreadcrumbCategoryId = categories => {
if (!!categories.length === false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing categories is an empty array when we get here and there is no category assigned to a product. In that case, let's just use a simple check against truthyness of categories and check whether there are any values in categories array, if it exists:

// Exit if there are no categories for this product.
if (!categories || !categories.length) {
  return;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@andrewbess Thanks for contributing! Looks like a simple fix. 👍

@sirugh Agreed, good suggestion.

Copy link
Author

Choose a reason for hiding this comment

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

Hello @sirugh
Thank you for review.
I have fixed it.
Please check.

@@ -97,6 +97,9 @@ const getMediaGalleryEntries = (product, optionCodes, optionSelections) => {
// product has multiple related categories. This function filters and selects
// one category id for that purpose.
const getBreadcrumbCategoryId = categories => {
if (!!categories.length === false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@andrewbess Thanks for contributing! Looks like a simple fix. 👍

@sirugh Agreed, good suggestion.

Copy link
Contributor

@sirugh sirugh left a comment

Choose a reason for hiding this comment

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

Thanks for making the suggested changes!

@andrewbess andrewbess requested a review from jimbo March 12, 2020 16:09
@dpatil-magento
Copy link
Contributor

Looks good.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants