/**
  * @param StoreEntity $storeEntity
  * @param CatalogEntity $catalogEntity
  * @param array $shopifyProducts
  */
 private function removeMissingShopifyProducts(StoreEntity $storeEntity, CatalogEntity $catalogEntity, array $shopifyProducts)
 {
     if (empty($shopifySkus)) {
         return;
     }
     $existingProducts = $this->skuToProductRepo->findBy(['storeId' => $storeEntity->getStoreId(), 'catalog' => $catalogEntity->getCatalogName()]);
     /** @var ShopifyProductEntity $shopifyProduct */
     foreach ($shopifyProducts as $shopifyProduct) {
         $shopifySkus[] = $shopifyProduct->getSku();
     }
     /** @var SkuToProductEntity $product */
     foreach ($existingProducts as $product) {
         if (!in_array($product->getSku(), $shopifySkus)) {
             $this->skuToProductRepo->remove($product);
         }
     }
     $this->skuToProductRepo->flush();
 }
Пример #2
0
 /**
  * @param StoreEntity $store
  * @param CatalogEntity $catalog
  * @param ErpProductEntity $product
  */
 public function getProductExtraInformation(StoreEntity $store, CatalogEntity $catalog, ErpProductEntity $product)
 {
     $request = $this->client->createRequest('GET', sprintf('%s/catalogs/%s/%s/all', $store->getErpUrl(), $catalog->getCatalogName(), $product->getSku()), ['auth' => [$store->getErpUsername(), $store->getErpPassword()]]);
     $response = $this->sendRequest($request)->xml();
     ErpProductEntity::updateProduct($product, $response);
 }
 /**
  * @param StoreEntity $store
  * @param CatalogEntity $catalog
  */
 public function createCollection(StoreEntity $store, CatalogEntity $catalog)
 {
     $this->setSettings($store);
     $response = $this->client->createCustomCollection(['custom_collection' => ['title' => $catalog->getCatalogName()]]);
     $catalog->setShopifyCollectionId($response['custom_collection']['id']);
 }