• Resolved alexisacseo

    (@alexisacseo)


    After migrating to 4.1,

    i didn’t find my products in wps_product table. It’s normal ?
    It’s the same thing for collection.

    Ca we get with the method get_product, the collection_id associated to a choosen product ? If yes, have you an example ?

    Thanks in advance

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author andrewmrobbins

    (@andrewmrobbins)

    @alexisacseo Hey there,

    Yes, in version 4.0 the product data is no longer saved to the wps_products table.

    You can fetch product data in PHP using the below functions:

    
    get_product()
    get_products()
    get_products_by_collection_ids()
    

    I have them all documented here: https://docs.wpshop.io/php-functions

    Let me know if this helps!

    Thread Starter alexisacseo

    (@alexisacseo)

    Hi,

    Yes the functions can help me but don’t respond of all my criteria.
    For exemple i will display all products in the same collection of one product.
    The function get_product, don’t display the collection information then i didn’t know the collection id :/
    Do you have an idea for that ?

    Thanks

    Plugin Author andrewmrobbins

    (@andrewmrobbins)

    @alexisacseo Hmm, so are you just looking to display all products from a specific collection based on collection title?

    Thread Starter alexisacseo

    (@alexisacseo)

    Hi For example,

    I go to the detail product page of a product an apple for example. Who is associated at the “fruits” collection.

    In the same page i want to display the fruits collection ordered in best selling fruits, to display a “cross sell”

    If i go to the detail page of the product sweatshirt, associated at the collection clothes, i want to display the collection clothes.
    Do you know want i mean, when i say, i did’nt know in advance the name of the collection i would like to display. It’s depend of the main product of my page.

    Plugin Author andrewmrobbins

    (@andrewmrobbins)

    @alexisacseo

    Ah, yeah this makes sense.

    The tricky part is that a single product can belong to multiple different collections.

    How do you want to determine which collection to pull from?

    We could fetch a list of all collections that a product belongs to, and then pick the first one from the list?

    Thread Starter alexisacseo

    (@alexisacseo)

    Hi Andrew,

    Thanks for your feedback.
    Just getting the collections_ids associated at one product, can be very great and helpfull

    With that i will able to retrieve products associated at the collection(s) with the function “get_products_by_collection_ids”

    If you have an idea for that i would be very great

    Plugin Author andrewmrobbins

    (@andrewmrobbins)

    @alexisacseo Ok, try this:

    
    $Products = ShopWP\Factories\API\Items\Products_Factory::build();
    $post_id = $post->ID; // required
    
    $result = $Products->get_product([
       'post_id' => $post_id,
       'schema' => '
          collections(first: 250) {
            edges {
                node {
                    id
                    title
                }
            }
          }
       '
    ]);
    

    That will return a list of collections that the product belongs to. It will only return the collection ID and collection title.

    Let me know if this helps!

    Thread Starter alexisacseo

    (@alexisacseo)

    Perfect for my needs !
    thanks a lot

    Plugin Author andrewmrobbins

    (@andrewmrobbins)

    @alexisacseo Awesome, no problem!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘product are not longer save in database’ is closed to new replies.