swellstores / swell-php

Swell API library for PHP
MIT License
8 stars 3 forks source link

Data is Protected. #1

Open kish2011 opened 2 years ago

kish2011 commented 2 years ago

I am using this PHP lib to access the products. But all data are protected.

Swell\Collection Object ( [count] => 2 [pages] => [page] => 1 [url:protected] => /products [links:protected] => Array ( [variants] => Array ( [url] => /products:variants?parent_id={id} )


How do I access it? I am using this. Object is protected.

$swell = new \Swell\Client('store-id', 'secret-key');

$products = $swell->get('/products', [ 'search' => 'press' ]);

Kushnerevich commented 2 years ago

@kish2011 You can use the url() and links() methods of the Collection object to access URLs and links. For details see: \Swell\Resource::url(), \Swell\Resource::links()

kish2011 commented 2 years ago

thanks @Kushnerevich

I am using this foreach ($products->records() as $record) { var_dump($record->data()['name']); }

I'll try them :)

Kushnerevich commented 2 years ago

@kish2011 $products is collection of products. It is iterable object. You can just do foreach, without ->records(). *(1)**

\Swell\Resource::url(), \Swell\Resource::links() are system information, it is not about products detail. If you would like work with product information you have to use your method or method *(1)**