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 get data about product from database in controller ?

Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

how to get data about product from database in controller ?

Welcome!

It looks like you're new here. Sign in or register to get started.
ยซ1

Comments

  • Lead Spryker Solution Architect / Technical Director Posts: 690 ๐Ÿช - Explorer

    Depends, if you want a list of products in Zed, have a look at Tables and Query Containers.
    If you wont to show some fields in Zed, have a look at the ProductFacade::getProductConcrete or ProductFacade::getProductAbstract.

    If you try to show a product field in the Frontend (Yves/Glue), https://documentation.spryker.com/docs/tutorial-architecture-walkthrough-scos will be a good place to start

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
    edited January 2020

    i want to get all data about product by id or sku in Zed

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Product concrete or Product abstract?

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    You can have at ProductFacadeInterface.

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Product abstract

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    @UKHD8KTMF so how i can use ProductFacadeInterface in controller ?

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    I need some context to be able to help you. Are you doing a page in Zed? Trying to show some data on frontend? Please explain your use case.

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Did you do developer bootcamp already https://training.spryker.com/courses/developer-bootcamp. It is free.

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    so when i create or update product i must send all data about it to other api i create custom module to catch this (Listener) but i not have data about product

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Did you do something like described here https://documentation.spryker.com/docs/event-listen

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    yes

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    public function handle(TransferInterface $eventTransfers, $eventName)
    {
    $data = array(
    'eventName' => $eventName,
    'data' => $_POST,
    );
    $this->sender->sendDataToApi($data);
    }

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    $_POST - are data from form

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    and $eventTransfers is empty

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    This looks wrong to me, because the event transfer should contain the data. How did POST data came to event listener? What are you listening for?

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    If I understand correctly, what you want is to call some external API when user creates a product in ZED.

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    yes exactly

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    You can use some of existing events - check ProductEvents

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    in my subscriber function

    private function createProductListener(EventCollectionInterface $eventCollection) {
            $eventCollection->addListener(ProductEvents::PRODUCT_ABSTRACT_AFTER_CREATE, new KacperListener());
            return $eventCollection;
        }
    
  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    and its go to my Listener and eventTransfer is empty

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    hmm, should not be $this->triggerEvent(ProductEvents::PRODUCT_ABSTRACT_AFTER_CREATE, $productAbstractTransfer);

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    you should have product abstract transfer - are you creating abstract product? maybe you are creating concrete product, but if event is triggered then I guess it is a correct one

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    You can put a breakpoint in ProductAbstractManager and debug if data is set

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    its my subscriber

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    could you change method and show me how to correctly ? I spent many hours on this

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    and docs is not clear for me

  • Posts: 393 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    can you share also KacperListener ?

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    okey

  • Posts: 92 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    kacperListener

  • Head of Solution Architecture @ Spryker Posts: 113 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
    edited January 2020

    Hi @USLUHK9SQ
    For having the product data in fronted stores, (Yves and Glue), we are using Publish and Synchronize (P&S) feature, this acts as CQRS method.
    long story short, we trigger events which contain the listener and some meta data information for publishing into database, then we aggregate and denormilize data and provide it via queue to Redis and ES.
    here you can find a simple HowTo tutorial
    https://documentation.spryker.com/docs/handling-data-publish-and-synchronization

Welcome!

It looks like you're new here. Sign in or register to get started.