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

[BUG] Category breadcrumbs path is missing #139

Open
1 task done
StanislovasRamanauskas opened this issue Apr 13, 2023 · 8 comments · May be fixed by #1369
Open
1 task done

[BUG] Category breadcrumbs path is missing #139

StanislovasRamanauskas opened this issue Apr 13, 2023 · 8 comments · May be fixed by #1369
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@StanislovasRamanauskas
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Currently useBreadcrumbs() composable only returns names array for category breadcrumbs. Paths are missing so link to category cannot be created.

E.G.

{
  "name": "Food"
}

Helper function to get breadcrumbs getCategoryBreadcrumbs() also gather only names:

export function getCategoryBreadcrumbs(
  category: Category | null | undefined,
  options?: {
    /**
     * Start at specific index if your navigation
     * contains root names which should not be visible.
     */
    startIndex?: number;
  }
) {
  const breadcrumbs =
    category?.translated?.breadcrumb || category?.breadcrumb || [];
  const startIndex = options?.startIndex || 0;
  if (breadcrumbs.length <= startIndex) return [];
  return breadcrumbs.slice(startIndex).map((element) => {
    return {
      name: element,
    };
  });
}

Breadcrumbs in product.seoCategory / category API response also contain only names. So I think this is issue both in BE and FE parts:
Screenshot from 2023-04-14 00-07-12

Expected Behavior

As declared in useBreadcrumbs return type I expect category breadcrumb with path returned:

type Breadcrumb = {
    name: string;
    path?: string;
};

Steps To Reproduce

No response

Environment

- OS:
- Node:
- npm:

Anything else?

No response

@BrocksiNet
Copy link
Collaborator

BrocksiNet commented Apr 14, 2023

Thx for submitting this already known issue (NEXT-24954). We have an discussion with the product area that is responsible to return the path via API. Also good to have this issue here to do not forget it. Will ping you when I have news about this.

Possible solutions:

In this file: src/Core/Content/Category/Service/CategoryBreadcrumbBuilder.php we could add after line 89 this line of code: $criteria->addAssociation('seoUrls'); and then we would have already the seoUrls in the response (slower).

Otherwise we could change public function getPlainBreadcrumb(): array function in src/Core/Content/Category/CategoryEntity.php and instead a flat array we return a super simple object that contains name and path (maybe path is already loaded, did not checked, then this would be faster).

@BrocksiNet BrocksiNet moved this to Is Blocked in Composable Frontends Apr 14, 2023
@patzick patzick added the core label Apr 14, 2023
@BrocksiNet
Copy link
Collaborator

@patzick could we use the same technic we used for "duplicated" seoURL''s calls to solve this issue? Like looking in the list if we have this seoURL already and then adding the link instead of waiting for the changed response? Just an idea.

@BrocksiNet
Copy link
Collaborator

@StanislovasRamanauskas here is an example of how to solve this in frontends (but this is just a workaround):
https://github.com/shopware/frontends/pull/258/files

And I do not know if we will merge this into the demo-store.

@BrocksiNet
Copy link
Collaborator

For reference: NEXT-24954

@junaidfarooqui
Copy link

@BrocksiNet Is there any news update about this issue 😄.

@BrocksiNet
Copy link
Collaborator

I am preparing the MR to get the new Endpoints into the Core of Shopware. After that, we can update the composables and have a proper solution. 🙌 But I need to find out which version it will be released.

@BrocksiNet
Copy link
Collaborator

The changes are already in the trunk so we can start with the frontend part. This is not blocked anymore.

@BrocksiNet BrocksiNet added enhancement New feature or request and removed core labels Oct 2, 2024
@mdanilowicz mdanilowicz self-assigned this Oct 4, 2024
@SuddenDev
Copy link

@BrocksiNet Do you have any news when this feature will be rolled out on Shopware Core? Since I've built a shop with 0.X versions of the frontend, I'll probably not refactor everything, but the API should still be accessible with fetch or similar tools if everything else fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Status: In Review
Development

Successfully merging a pull request may close this issue.

6 participants