Example #1
0
 /**
  * Merge data from Buscape with the ccollection of products and set the this data property
  *
  * @param ProductCollection $products
  * @param $responseData
  */
 public function mergeData(ProductCollection $products, $responseData)
 {
     $this->data = new ProductCollection();
     if ($products->getErrors()) {
         $this->data->addValidationResponse($products->getErrors());
     }
     foreach ($products as $key => $product) {
         if (empty($responseData[$key])) {
             continue;
         }
         if (!empty($responseData[$key]['status'])) {
             $product->setStatus($responseData[$key]['status']);
         }
         if (!empty($responseData[$key]['errors'])) {
             $product->setErrors($responseData[$key]['errors']);
         }
         $this->data->addProductResponse($product);
     }
 }