Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

How to fetch database data to frontend in Spryker?

Options
U04TG4PBDL1
U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
edited May 2023 in Help

HI TEAM, can anyone guide me how to fetch database data to frontend in spryker. any guide link?

Comments

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,029 ⚖️ - Guardians (admin)
    Options

    Hey,
    please have a look at the developer learning plan at academy.spryker.com 🙂

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    i checked im not getting that tutorial can u give me link?

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,029 ⚖️ - Guardians (admin)
    Options

    Have a look here: https://academy.spryker.com/learn/public/learning_plan/view/73/spryker-backend-fundamentals

    the persist and fetch one is one way to learn; for projects you would likely use publish&synchronize

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    Depends on the kind of data.

    If it's non customer related data, like products, availabilities, etc. you don't retrieve the data from the database but from the storage (redis), where it get's synchronized into via publish & synchronize (https://docs.spryker.com/docs/scos/dev/back-end-development/data-manipulation/data-publishing/publish-and-synchronization.html)

    If it's customer related data, like addresses, or the data needs a live calculation, like cart sums, you retrieve the data from the backend application (Zed Gateway) which fetchs the data from the database (https://docs.spryker.com/docs/scos/dev/back-end-development/data-manipulation/data-interaction/transfer-data-between-yves-and-zed.html#imple[…]lient).

    The frontend (Yves/Glue) should not have direct access to the database as this would reduce the scaleability of your shop.

    There is a possibility to replace the storage with database access (https://docs.spryker.com/docs/scos/dev/tutorials-and-howtos/howtos/howto-replace-key-value-storage-with-database.html), but this is a scenario you should only choose if you have a very few customers, but a high amount of products/categories/etc. For example in some B2B scenarios. But as I assume by the question that you are not too familiar with Spryker better forget about this scenario for now, as it applies only to a few edge cases.

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    im having one more doubt. in frontend breadcrumb value is fetched. how you can show it as page title

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    • in this screenshot. the u can see breadcrumb value Home / Customer Account / Quote Requests / #RED--1-15
    So i want o show #RED--1-15 as separate page title

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    There is the metaTitle block in the page-blank.twig which means on product abstract and product concrete pages you could overwrite it in the related template and use the breadcrumb from ProductViewTransfer->getCategoriesBreadcrumb()

    On other parts, like quote request, you will need to find the right template (either you have already a page-layout, like page-layout-customer.twig or you need to modify the related view to overwrite the above mentioned metaTitle

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    For quote requests there already exists a page-layout you can overwrite in your project code: page-layout-quote-request.twig

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    Please can u tell me in which folder is page-blank.twig file?

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    i want to place this code in twig file. how to keep it as separate block of html code

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    {{data.quoteRequest.quoteRequestReference}}

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    src/Pyz/Yves/ShopUi/Theme/default/templates/page-blank/page-blank.twig (if it does not exists, create it and extend the core one):

    {% extends template('page-blank', '@SprykerShop:ShopUi') %}
    
  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    i want to place this code in twig file. how to keep it as separate block of html code

    This is something which should be done in the more specific page layout page-layout-quote-request.twig (in src/Pyz/Yves/QuoteRequestPage/Theme/default/templates/page-layout-quote-request/page-layout-quote-request.twig , again if it does not exist, create it)

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    Can u tell me how to hide the title in twig file based on condition of quote request such as approved, rejected, in progress.

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    {% if data.quoteRequest.status == '<your status>' %}

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    ok

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    can i send u file will u help me in doing it?

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    No, sorry if you need someone to implement your requirements for you, either you can hire my company (Smart Commerce SE) or you can learn how and where to implement things.
    I'm happy to help on the learning journey, but I wan't do the work for you.

    There is an excellent tutorial on twig available at https://twig.symfony.com/doc/3.x/api.html, as well as the https://academy.spryker.com/learn/course/external/view/elearning/381/spryker-frontend-for-backend-developers course for the spryker specific parts.

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    ok. thanks

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    Hi .can u give me idea how to group bundled products in backoffice in Quote request page which is stored in database.?

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    Like bundle 1, bundle 2... etc

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    ??

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    i have database column in which values are stored based on that column i want to fetch on backoffice quote request page. Can anybody give me idea how to do it?

  • U04TG4PBDL1
    U04TG4PBDL1 Posts: 49 🧑🏻‍🚀 - Cadet
    Options

    Hi .can u give me idea how to sort cart items in spryker in backoffice? can i do it directly in twig file or should i make use of controller?