1

I'm developing a mobile app to connect with my Drupal Commerce (Kickstart) store, using a REST server.

When I do GET: endpoint/rest/product it retrieves the products list

<result is_array="true">
    <item>
        <revision_id>1</revision_id>
        <sku>TOT1-GRN-OS</sku>
        <title>Tote Bag 1</title>
        <revision_uid>1</revision_uid>
        <status>1</status>
        <log />
        <revision_timestamp>1423972403</revision_timestamp>
        <data />
        <product_id>1</product_id>
        <type>bags_cases</type>
        <language>und</language>
        <uid>1</uid>
        <created>1423972403</created>
        <changed>1423972403</changed>
        <title_field>Tote Bag 1</title_field>
        <commerce_price>
            <amount>1600</amount>
            <currency_code>EUR</currency_code>
            <data>                <components />
                </data>
        </commerce_price>
        ...
    </item>
    <item>
     ...
    </item>

Everything looks fine. I can even GET endpoint/rest/product?status=1 and it does filter well.

I'm trying to filter by commerce_price.amount:

GET endpoint/rest/product?commerce_price.amount=1600

but it's not working. I have no problems filtering by a first level key, but can't access second level ones and so on. What am I doing wrong?

1

From what I understand, querying only works on entity properties. That is why status works, commerce_price is a field and won't work. Checkout Services Entity API, it may do what you're looking for.

You may still be out of luck though. You alternatives will be to use services_views or write your own Services Resource.

  • Additionally, a commerce price is a different entity type to a commerce product. Being able to query by fields wouldn't be enough for this, you'd also need the api module to resolve the entity reference as well. Be nice, but I doubt anyone's gone to those lengths – Clive Apr 14 '15 at 14:24
  • @Clive I think you're exactly right. I updated my answer to mention services_views or a custom resource right after i posted my initial answer. – Cravecode Apr 14 '15 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.