src/Entity/Product.php
public function toNode(DOMDocument $document = null)
    {
        if (null === $document) {
            $document = new DOMDocument();
        }

        $node = $document->createElement('Product');
        for ($i = 1; $i <= 3; $i++) {
            $desc = $this->{'getDescription'.$i}();
            if ($desc !== null) {
                $node->appendChild($document->createElement('Description', $desc));
            }
        }
        if ($this->getUnit() !== null) {
            $node->appendChild($this->getUnit()->toNode($document));
        }
        if ($this->getCommodityCode() !== null) {
            $node->appendChild($document->createElement('CommodityCode', $this->getCommodityCode()));
        }
        if ($this->getPartNumber() !== null) {
            $node->appendChild($document->createElement('PartNumber', $this->getPartNumber()));
        }
        if ($this->getOriginCountryCode() !== null) {
            $node->appendChild($document->createElement('OriginCountryCode', $this->getOriginCountryCode()));
        }

        return $node;
    }
public function toNode(DOMDocument $document = null)
    {
        if (null === $document) {
            $document = new DOMDocument();
        }

        $node = $document->createElement('Product');
        for ($i = 1; $i <= 3; $i++) {
            $desc = $this->{'getDescription'.$i}();
            if ($desc !== null) {
                $node->appendChild($document->createElement('Description', $desc));
            }
        }
        if ($this->getUnit() !== null) {
            $node->appendChild($this->getUnit()->toNode($document));
        }
        if ($this->getCommodityCode() !== null) {
            $node->appendChild($document->createElement('CommodityCode', $this->getCommodityCode()));
        }
        if ($this->getPartNumber() !== null) {
            $node->appendChild($document->createElement('PartNumber', $this->getPartNumber()));
        }
        if ($this->getOriginCountryCode() !== null) {
            $node->appendChild($document->createElement('OriginCountryCode', $this->getOriginCountryCode()));
        }

        return $node;
    }
@param null|DOMDocument $document

@return DOMElement