/** * @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); }