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, for the merchant relationship feature, there is a `spy_merchant_relationship` table which rep

UPWG9AYH2
UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

Hello,
for the merchant relationship feature, there is a spy_merchant_relationship table which represents the m:n mapping between the spy_merchant and spy_company_business_unit using the the ids of both as foreign key in spy_merchant_relationship
However, there is another table spy_merchant_relationship_to_company_business_unit which represents another m:n relation between spy_company_business_unit and spy_merchant_relationship
Do i miss something or isn’t the second table some kind of redundant information since its already represented by the first one?
I just wonder why my relation was not created but it seems my facade call didn’t consider this table.
Best

Comments

  • Eugenia Poidenko
    Eugenia Poidenko Sprykee Posts: 145 🧑🏻‍🚀 - Cadet

    spy_merchant_relationship_to_company_business_unit is for assigned business units, they can be multiple - these BU will be affected by the relationship config

  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 🧑🏻‍🚀 - Cadet
    spy_merchant_relationship.fk_company_business_unit
    

    represents which business unit is owner of this merchant_relationship

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    So retrieving the merchant relationship via the company_user transfer means, that it just filled when the company_business_unit is the owner of the merchant relationship?

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    edited March 2021

    i mean, i created a relationship via the merchant relationship facade … but then i fetched the company user and the hydrated company unit and i expected the merchant relation to be the one that i created right now … but it seems that this is not true. instead it might be the ownership as already mentioned

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    edited March 2021

    Is the “ownership” of the relation necessary? I don’t think so since the creation process in the facade didn’t throw any error …. but it also did not create an entry in spy_merchant_relationship_to_company_business_unit

  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 🧑🏻‍🚀 - Cadet
    edited March 2021
    <column name="fk_company_business_unit" required="true" type="INTEGER"/>
    

    it is requried for merchant relationship entity.

    $merchantRelationTransfer
        ->requireFkMerchant()
        ->requireFkCompanyBusinessUnit();
    

    To save business units to merchant relationship via MerchantRelationshipFacade::create

    add

    $merchantRelationTransfer->setAssigneeCompanyBusinessUnits((new CompanyBusinessUnitCollectionTransfer())->setCompanyBusinessUnits($companyBusinessUnitTransfers));
    
  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 🧑🏻‍🚀 - Cadet
    CompanyBusinessUnitTransfer->idCompanyBusinessUnit
    

    is only required in this case

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    Thanks a lot … 🙂 last question i didn’t ask yet: what is this ownership needed for? When using the merchant related price between merchant and a business unit, what relation i should look for? The “ownership” between the business_unit/merchant_relationship (represented by spy_merchant_relationship_to_company_business_unit) or the collection of spy_merchant_Relationship? I am a bit confused, sorry^^

  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 🧑🏻‍🚀 - Cadet
    edited March 2021

    for prices only relations via spy_merchant_relationship_to_company_business_unit matters

  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 🧑🏻‍🚀 - Cadet
    $merchantRelationshipTransfer->getOwnerCompanyBusinessUnit()
    

    Could be used for some business logic, in Spryker modules it's used to display related to merchant relationship Company and combine it with Business Unit name, e.g. Company X (Sales Departement)

  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 🧑🏻‍🚀 - Cadet

    also you cannot assign merchant relationship to another company business units if this one owned by business unit from different company

  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 🧑🏻‍🚀 - Cadet

    I think that is all 🙂