getProduct(); if ($product === null) { throw new \RuntimeException('NormalizeJob requires an existing ProductDTO.'); } $result->addLog(sprintf('[%s] normalizing product data for %s.', $this->getName(), $product->getName())); $normalizedProduct = new ProductDTO( $product->getId(), trim($product->getName()), $product->getDescription() !== null ? trim($product->getDescription()) : null, $product->getShortDescription() !== null ? trim($product->getShortDescription()) : null, $product->getPrice() ?? new PriceDTO('EUR', 0.0), $product->getInventory() ?? new InventoryDTO(0, false, true), $product->getCategories(), $product->getImages(), $product->getAttributes(), $product->getSeo() ?? new SeoDTO(), $product->getProviderInfo() ?? new ProviderInfoDTO('unknown'), $product->getSku() ?? new SKU(''), $product->getBarcode() ?? new Barcode($product->getId()) ); $result->setProduct($normalizedProduct); $result->addLog(sprintf('[%s] normalized product with id %s.', $this->getName(), $normalizedProduct->getId())); return $result; } }