/**
  * @param StoreEntity $store
  * @param CatalogEntity $catalog
  * @param $limit
  * @param $page
  * @param $collection
  * @return array
  */
 public function getProductsByCollection(StoreEntity $store, CatalogEntity $catalog, $limit, $page, &$collection)
 {
     $this->setSettings($store);
     $response = $this->client->getProducts(['collection_id' => (int) $catalog->getShopifyCollectionId(), 'limit' => (int) $limit, 'page' => $page]);
     foreach ($response['products'] as $product) {
         $collection[] = ShopifyProductEntity::createFromResponse($product);
     }
     return $collection;
 }
Exemple #2
0
 /**
  * @depends testProductDelete
  */
 public function testProductPagination()
 {
     for ($i = 0; $i <= 9; $i++) {
         $this->client->createProduct(['title' => 'test product ' . $i]);
     }
     $counter = 0;
     foreach ($this->client->getResourcePager('products', 5) as $product) {
         $this->assertNotEmpty($product);
         $this->assertObjectHasAttribute('title', $product);
         $this->assertEquals('test product ' . $counter, $product->title);
         $counter++;
     }
     $this->assertEquals(10, $this->client->getProductsCount(), 'There should be 10 products in the system.');
     $opts['query']['limit'] = 5;
     foreach ($this->client->getProducts($opts) as $product) {
         $this->assertObjectHasAttribute('id', $product);
         $this->client->deleteProduct($product->id);
     }
     $this->assertEquals(0, $this->client->getProductsCount(), 'Not all products were deleted.');
 }