Supplier/EventListener/SupplierOrderItemListener.php
protected function synchronizeWithProduct(SupplierOrderItemInterface $item)
    {
        $changed = false;

        // TODO What about stock management if subject change ???
        if (null !== $product = $item->getProduct()) {
            // TODO Create an utility class to do this
            $productSID = $product->getSubjectIdentity();
            if ($productSID->hasIdentity()) {
                $itemSID = $item->getSubjectIdentity();

                if ($itemSID->hasIdentity()) {
                    if (!$itemSID->equals($productSID)) {
                        throw new LogicException(
                            'Breaking synchronization between supplier order item and supplier product is not supported.'
                        );
                    }
                    $changed = false;
                } else {
                    $itemSID->copy($productSID);
                    $changed = true;
                }
            } else {
                throw new InvalidArgumentException(
                    'Supplier product subject identity is not set.'
                );
            }

            if (0 == strlen($item->getDesignation())) {
                $item->setDesignation($product->getDesignation());
            }
            if (0 == strlen($item->getReference())) {
                $item->setReference($product->getReference());
            }
            if (0 == $item->getNetPrice()) {
                $item->setNetPrice($product->getNetPrice());
            }
        } elseif ($item->hasSubjectIdentity()) {
            throw new LogicException(
                'Breaking synchronization between supplier order item and supplier product is not supported.'
            );
        }

        return $changed;
    }
protected function synchronizeWithProduct(SupplierOrderItemInterface $item)
    {
        $changed = false;

        // TODO What about stock management if subject change ???
        if (null !== $product = $item->getProduct()) {
            // TODO Create an utility class to do this
            $productSID = $product->getSubjectIdentity();
            if ($productSID->hasIdentity()) {
                $itemSID = $item->getSubjectIdentity();

                if ($itemSID->hasIdentity()) {
                    if (!$itemSID->equals($productSID)) {
                        throw new LogicException(
                            'Breaking synchronization between supplier order item and supplier product is not supported.'
                        );
                    }
                    $changed = false;
                } else {
                    $itemSID->copy($productSID);
                    $changed = true;
                }
            } else {
                throw new InvalidArgumentException(
                    'Supplier product subject identity is not set.'
                );
            }

            if (0 == strlen($item->getDesignation())) {
                $item->setDesignation($product->getDesignation());
            }
            if (0 == strlen($item->getReference())) {
                $item->setReference($product->getReference());
            }
            if (0 == $item->getNetPrice()) {
                $item->setNetPrice($product->getNetPrice());
            }
        } elseif ($item->hasSubjectIdentity()) {
            throw new LogicException(
                'Breaking synchronization between supplier order item and supplier product is not supported.'
            );
        }

        return $changed;
    }
Synchronises with the supplier product.

@param SupplierOrderItemInterface $item

@return bool Whether or not the item has been changed.

@throws LogicException If breaking synchronization between supplier order item and supplier product.
@throws InvalidArgumentException If supplier product subject data is not set.