Giter Club home page Giter Club logo

Comments (5)

Toflar avatar Toflar commented on June 2, 2024

Any feedback on this? I'll happily work on a PR but I want to get some feedback on the concept :)

from api-php-client.

ahocquard avatar ahocquard commented on June 2, 2024

Hello and sorry for the late response.

  • First point:
    I don't understand how the "count" could be returned with the all method.
    It's a cursor returning the directly entities, not the page itself.

  • Second point:
    I strongly discourage you to do it this way for performance concern.
    The cursor is, under the hood, iterating by doing several requests. So, it would count each time for every requests. It can have an impact on the performance on pretty big catalogs.

I advise you to get the count with the listPerPage method, and then iterate over the categories with the all.

$categoryCount = $client->getProductApi()->listPerPage(1, true)->getCount();
$categories = $client->getCategoryApi()->all(100);

from api-php-client.

Toflar avatar Toflar commented on June 2, 2024

Thanks for the reply but I don't think you understood the issue exactly :-) As far as I understood from the API docs (https://api.akeneo.com/api-reference-21.html#get_categories), the with_count parameter adds the number of products per category to the result. It's not related to pagination or the cursor at all, is it?

What I need is the number of products per category so I can build something like this:

  • Category A (512)
    • Category C (18)
    • Category D (494)
  • Category B (32)

from api-php-client.

ahocquard avatar ahocquard commented on June 2, 2024

Hello,

No, this count is the total number of categories.

If you want to get the number of products in a category, you have to request the product endpoint with a filter IN CHILDREN:
https://api.akeneo.com/documentation/filter.html#on-categories

It's not possible to do it in 1 request for several categories though.

from api-php-client.

Toflar avatar Toflar commented on June 2, 2024

Ah, I see. Thank you for taking the time to reply then 👍

from api-php-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.