OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce Providing data from database to data provider services

This topic contains 7 replies, has 3 voices, and was last updated by  Michael 5 years, 5 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #37598

    nellybaz10
    Participant

    Hello there,
    am relatively new to orocommerce application and not so conversant with symfony.

    I need to create a service that retrieves product data from the database and sends to my layout.
    Pls, how do I go about it?
    Is there an orocommerce service that already exists that I can use?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #37601

    mlukaszewicz
    Participant

    Hello,

    the get information from DB you should use Repository, in your case it would be ProductRepository.
    Please check symfony doc: https://symfony.com/doc/2.8/doctrine.html#fetching-objects-from-the-database to get more info how to use Repositories.

    Best,
    Martin

    #37602

    nellybaz10
    Participant

    OKay, thank you.
    One more thing. If I fetch product image and get a value like this 38dns9xnsu.jpeg,
    how do I use the image name to display it in the tag.
    becasue I did somthing like this

    and its not working.

    Thanks in advance

    • This reply was modified 5 years, 5 months ago by  nellybaz10.
    • This reply was modified 5 years, 5 months ago by  nellybaz10.
    #37605

    nellybaz10
    Participant

    hello, pls am still hoping for the answers to my question.
    Thanks

    #37606

    Michael
    Keymaster

    It depends on what and how you are trying to do, but if you have chosen the approach similar to the default OroCommerce theme, you can use the existing macros from OroProductBundle::image_macros.html.twig to do it for you. For example, here is how it is done in the default theme:

    #37607

    nellybaz10
    Participant

    Thanks a lot.
    Is there an alternative way to do that?
    This is my code

    And this is my twig file

    #37614

    nellybaz10
    Participant

    Hello,
    I would really appreciate assistance on this
    As they is no guide on docs on how to do this
    Thanks

    #37617

    Michael
    Keymaster

    Is there some specific reason you do not want to use the existing macros?
    As an alternative way you can probably check what the Twig functions called in these macros do, and reimplement them yourself, but I do not see any benefits to such approach.

Viewing 7 replies - 1 through 7 (of 7 total)

The forum ‘OroCommerce’ is closed to new topics and replies.

Back to top