How to use PHP functions
-
Hi there,
I’m trying to use the PHP function to retrieve a list of products by a given collection id. Therefore I have these two lines of code in my template
$Products = WP_Shopify\Factories\DB\Products_Factory::build();
$result = $Products->get_products_by_collection_ids(164430086192);where 164430086192 is the code of the collection I want to show the products of.
When I print_r($result) I get an empty array(). If I print_r($Products) I get
WP_Shopify\DB\Products Object ( [table_name_suffix] => wps_products [table_name] => wp_wps_products [version] => 1.0 [primary_key] => id [lookup_key] => product_id [cache_group] => wps_db_products [type] => product [default_product_id] => 0 [default_post_id] => 0 [default_title] => [default_body_html] => [default_handle] => [default_post_name] => [default_image] => [default_images] => [default_vendor] => [default_product_type] => [default_published_scope] => [default_published_at] => 2020-10-21 13:46:32 [default_updated_at] => 2020-10-21 13:46:32 [default_created_at] => 2020-10-21 13:46:32 [default_admin_graphql_api_id] => [default_metafields_global_title_tag] => [default_metafields_global_description_tag] => [metafields_global_title_tag] => [metafields_global_description_tag] => )
Am I using that function correctly?
Many thanks
Jeff
- The topic ‘How to use PHP functions’ is closed to new replies.