public static function createFromXMLResponse(\SimpleXMLElement $response)
 {
     $self = new self();
     $catalog = $response->attributes()->PriceListCode ? (string) $response->attributes()->PriceListCode : null;
     if (is_null($catalog)) {
         throw new \InvalidArgumentException('Invalid Catalog received from ERP system');
     }
     $self->setCatalog($catalog);
     $products = [];
     foreach ($response->Category->Product as $product) {
         $products[] = ErpProductEntity::createFromCatalogXmlResponse($product);
     }
     if (empty($products)) {
         throw new \InvalidArgumentException('No products to import');
     }
     $self->setProducts($products);
     return $self;
 }
 /**
  * @param ErpProductEntity $product
  * @param \SimpleXMLElement $data
  */
 public static function updateProduct(ErpProductEntity $product, \SimpleXMLElement $data)
 {
     if ($product->getSku() != $data->attributes()->ItemNo) {
         throw new \InvalidArgumentException(sprintf('product %s is not the same as the response product %s', $product->getSku(), $data->attributes()->ItemNo));
     }
     $product->setInventoryPolicy($data->ItemSpecialString && $data->ItemSpecialString == "1" ? 'continue' : 'deny');
     $product->setStockManagement($data->ItemSpecialString && $data->ItemSpecialString == "1" ? '' : 'shopify');
     $product->setFulFilmentService('manual');
     if (isset($data->ImageSource)) {
         $product->setImage((string) $data->ImageSource);
     }
     $fullDescription = '';
     foreach ($data->TextDescription as $line) {
         $fullDescription .= $line . ' ';
     }
     $product->setFullDesription($fullDescription);
 }