/** * Bind target entities * * @param AbstractAssociation $association * @param ProductInterface[] $appendProducts * @param ProductInterface[] $removeProducts * @param Group[] $appendGroups * @param Group[] $removeGroups */ protected function bindTargets(AbstractAssociation $association, array $appendProducts, array $removeProducts, array $appendGroups, array $removeGroups) { foreach ($appendProducts as $product) { $association->addProduct($product); } foreach ($removeProducts as $product) { $association->removeProduct($product); } foreach ($appendGroups as $group) { $association->addGroup($group); } foreach ($removeGroups as $group) { $association->removeGroup($group); } }
/** * Get create calls. * * @param ProductInterface $product * @param AbstractAssociation $association * * @return array */ protected function getCreateCallsForAssociation(ProductInterface $product, AbstractAssociation $association) { $createAssociationCalls = []; $associationType = $association->getAssociationType()->getCode(); if (in_array($associationType, array_keys($this->getAssociationCodeMapping()))) { foreach ($association->getProducts() as $associatedProduct) { $createAssociationCalls[] = ['type' => $this->getAssociationCodeMapping()[$associationType], 'product' => (string) $product->getIdentifier(), 'linkedProduct' => (string) $associatedProduct->getIdentifier(), 'identifierType' => 'sku']; } } return $createAssociationCalls; }