protected function setAddonData(
        ItemInterface $lastProcessedProductItem,
        ItemInterface $item,
        ProductInterface $parentItemProduct = null
    ) {
        $item->setParent($lastProcessedProductItem);

        $parentProduct = $lastProcessedProductItem->getProduct();
        $addonProduct = $item->getProduct();
        /** @var Addon $addon */
        $addon = $this->addonRepository->findOneBy(['product' => $parentProduct, 'addon' => $addonProduct]);

        // Check if parent product has an addon relation.
        if (!$addon && $parentItemProduct) {
            $addon = $this->addonRepository->findOneBy(['product' => $parentProduct, 'addon' => $parentItemProduct]);
        }

        if (!$addon) {
            throw new \Exception(
                'Addon id ' . $addonProduct->getId() . ' for product id ' . $parentProduct->getId() . ' not found.'
            );
        }
        $item->setAddon($addon);

        return $addon;
    }
protected function setAddonData(
        ItemInterface $lastProcessedProductItem,
        ItemInterface $item,
        ProductInterface $parentItemProduct = null
    ) {
        $item->setParent($lastProcessedProductItem);

        $parentProduct = $lastProcessedProductItem->getProduct();
        $addonProduct = $item->getProduct();
        /** @var Addon $addon */
        $addon = $this->addonRepository->findOneBy(['product' => $parentProduct, 'addon' => $addonProduct]);

        // Check if parent product has an addon relation.
        if (!$addon && $parentItemProduct) {
            $addon = $this->addonRepository->findOneBy(['product' => $parentProduct, 'addon' => $parentItemProduct]);
        }

        if (!$addon) {
            throw new \Exception(
                'Addon id ' . $addonProduct->getId() . ' for product id ' . $parentProduct->getId() . ' not found.'
            );
        }
        $item->setAddon($addon);

        return $addon;
    }
protected function setAddonData ( ItemInterface $ lastProcessedProductItem , ItemInterface $ item , ProductInterface $ parentItemProduct = null ) { $ item -> setParent ( $ lastProcessedProductItem ) ; $ parentProduct = $ lastProcessedProductItem -> getProduct ( ) ; $ addonProduct = $ item -> getProduct ( ) ; /** @var Addon $addon */ $ addon = $ this -> addonRepository -> findOneBy ( [ 'product' => $ parentProduct , 'addon' => $ addonProduct ] ) ; // Check if parent product has an addon relation. if ( ! $ addon && $ parentItemProduct ) { $ addon = $ this -> addonRepository -> findOneBy ( [ 'product' => $ parentProduct , 'addon' => $ parentItemProduct ] ) ; } if ( ! $ addon ) { throw new \ Exception ( 'Addon id ' . $ addonProduct -> getId ( ) . ' for product id ' . $ parentProduct -> getId ( ) . ' not found.' ) ; } $ item -> setAddon ( $ addon ) ; return $ addon ; }
Set addon data to item.

@param ItemInterface $lastProcessedProductItem
@param ItemInterface $item
@param ProductInterface $parentItemProduct Items product parent product.

@throws \Exception

@return Addon
Set addon data to item .