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..

Hello. I need to fetch orders using customn filters. I also need payment information. Why there is n

U0145CP9Q6Q
U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

Hello. I need to fetch orders using customn filters. I also need payment information. Why there is no relation to spy_sales_payment table in src/Orm/Zed/Sales?
And how can I properly add joining with this table?
Thanks.

Β«1

Comments

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    hey alex πŸ‘‹ πŸ™‚

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    Hi Andreas :)

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    I am not tooo close to all that, but my assumption is that in spryker ootb, different payment type is typically represented by different order state machine being used/assigned to order (order items)

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    on previous projects, we changed that to have few state machine processes dealing with different payment types and stored a reference to payment information

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    I believe though that payment information is stored somewhere for orders, can’t remember where πŸ˜‡

  • UKJND3A3H
    UKJND3A3H Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    β€œfetch orders using custom filters”: that’s for which layer? yves? zed?

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    I need orders for zed.
    Yes i know that there can be different state machines and etc.. But i'm didn't create any new state machines.
    Just using OOTB functionality. I can join with everything (spy_sales_shipment, spy_sales_order_items etc) but not with payment. They put shipment relations into src/Orm/Zed/Sales but Pyament relations went somehow to src/Orm/Zed/Payment . And there is a relation to spy_sales_payment table. As for me it looks weird.
    And when using \Orm\Zed\Sales\Persistence\SpySalesOrderQuery i can't join to spy_sales_payment table. But in this table there is foreign key to order_id

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    Join methods are generated here \Orm\Zed\Sales\Persistence\Base\SpySalesOrderQuery . But since there is no relation to payment - this method doesn't exist

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    Hi @U0145CP9Q6Q if you want to join with payments, then you should be looking fo SpySalesOrderQuery and it’s payment-related methods

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    order itself doesn’t have foreign key to payment, but payment does. That’s why relation and model methods should be present

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    hi @UKJSE6T47. That is what i'm talking about.
    Methods should be present in \Orm\Zed\Sales\Persistence\Base\SpySalesOrderQuery but they don't.

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    Maybe i need to regenerate smth? or maybe you have another options

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    @U0145CP9Q6Q hmmm, can you try something, I think I found an issue

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    please check SpySalesOrderQuery::useOrderQuery()

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    it seems that the php relation name in propel schema was wrongly named

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    exactly

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    this is the reason, should be named after β€œPayment” instead.

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    changing that on Spryker side will mean a major update. But we will see what we can do here.

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited May 2020

    so should be SalesOrder?

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    or what is the correct variant?

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    I think you don’t need to change anything. Just use for now useOrderQuery() method. If you like, you can introduce β€œusePaymentQuery()” and other similar one-s in your Orm\Zed\Sales\Persistence\SpySalesOrderQuery and push it to your code base, that will help you to avoid further confusement

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    plus I don’t think you can overwrite phpName and refPhpName properties coming from core on project level..

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok. thanks. also another question since you are here so far.
    I need also shippng cost. I see that you have spy_sales_shipment table. But there is only name. On item level I also don't see anything. How can i get the shipping cost for order? I see shipping costs only in spy_shipment_method_price . But this is not related to sales as for me

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    I'm using joinWithSpySalesShipment but it gives me everything except shipping costs

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    In spryker, shipping costs are added to the expenses, which you can find in spy_sales_order_total.order_expense_total

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    if you need more granular information about expenses (especially if you have multi-shipment or another expenses), you can check the spy_sales_expense table. There you have β€œtype” column that can give you an idea about what kind of expense it is

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    thanks

  • U0145CP9Q6Q
    U0145CP9Q6Q Posts: 123 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UKJSE6T47 again about useOrderQuery method. It will return to me the instance of SpySalesPaymentQuery. So the result will contain only payment data but not order's data. How to make it to be in result of SpySalesOrderQuery?

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited May 2020

    It should look like this, approx.

    $ordersQuery
    ->useOrderQuery() 
    ->   withColumn(SpySalesPaymentTableMap::COL_ID_PAYMENT, 'payment_id')
    ->endUse()
    ->find()
    ->toArray()
    
  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    the formatting is crap.. You can find lots of examples in spryker core code, by searching for β€œ->use” in the code base