Making Requests

Once a client has been initialized, you may make requests to Shopify using the available methods.

Let's take a look at a couple of examples:

$shopify = \Pactode\Shopify\Factory::fromConfig();

// Paginate products
$cursor = $shopify->paginateProducts(); // returns a Cursor

// Get products count
$count = $shopify->getProductsCount(); // returns an integer

// Get products
$products = $shopify->getProducts(); // returns a Collection of ProductResource

// Create a product
$product = $shopify->createProduct([
    'title' => 'Adidas Shoe, Pink',
]); // returns a ProductResource

// Get a specific product
$product = $shopify->getProduct($productId); // returns a ProductResource

// Update a product
$product = $shopify->updateProduct($productId, [
    'title' => 'Adidas Shoe, Rose',
]); // returns a ProductResource 

// Deleting a product
$shopify->deleteProduct($productId);

Please refer to the official documentation to check which attributes are required for each request. The resource key in the payload will be populated to your payload automatically based on the method, i.e. "product" for the createProduct method.

Last updated