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

Hi, has anyone queried business units before based on the company? All I found was the `getCompanyBu

ULL0N440J
ULL0N440J Posts: 184 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
edited December 2019 in Help

Hi,
has anyone queried business units before based on the company? All I found was the getCompanyBusinessUnits in project/src/Orm/Zed/Company/Persistence/Base/SpyCompany.php : 2142. Don't know how to take use of this.

Comments

  • Eugenia Poidenko
    Eugenia Poidenko Sprykee Posts: 145 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    I think the method will be available on the entities you will retrieve from the DB with query. For example:

    (new SpyCompanyQuery())->findOneByIdCompany(1)->getCompanyBusinessUnits();
    

    I think you can also do

    (new SpyCompanyBusinessUnitQuery())->findByFkCompany(1);
    
  • jochen.gartner
    jochen.gartner Posts: 42 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    you're question sounds as if you should look into propel fundamentals first. anyway, you can find what you're looking for in CompanyBusinessUnitFacade::getCompanyBusinessUnitCollection.

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

    Thank you both ๐Ÿ™‚ This way worked for me:

    $repository = new CompanyBusinessUnitRepository();
    $criteria = $companyBusinessUnitCriteriaFilter = (new CompanyBusinessUnitCriteriaFilterTransfer())
        ->setIdCompany($companyId);
    $companyBusinessUnitsCollection = $repository->getCompanyBusinessUnitCollection($criteria);