/** * @param \Generated\Shared\Transfer\ProductAbstractTransfer $product * * @return bool */ public function writeProductAbstract(ProductAbstractTransfer $product) { $this->productStatement->execute([':sku' => $product->getSku(), ':attributes' => json_encode($product->getAttributes())]); foreach ($product->getLocalizedAttributes() as $localizedAttributes) { $this->attributesStatement->execute([':attributes' => json_encode($localizedAttributes->getAttributes()), ':name' => $localizedAttributes->getName(), ':productAbstractSku' => $product->getSku(), ':fkLocale' => $this->localeTransfer->getIdLocale()]); } return true; }
/** * @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer * * @return void */ protected function createProductAbstractAttributes(ProductAbstractTransfer $productAbstractTransfer) { $idProductAbstract = $productAbstractTransfer->getIdProductAbstract(); foreach ($productAbstractTransfer->getLocalizedAttributes() as $localizedAttributes) { $locale = $localizedAttributes->getLocale(); if ($this->hasProductAbstractAttributes($idProductAbstract, $locale)) { continue; } $encodedAttributes = $this->encodeAttributes($localizedAttributes->getAttributes()); $productAbstractAttributesEntity = new SpyProductAbstractLocalizedAttributes(); $productAbstractAttributesEntity->setFkProductAbstract($idProductAbstract)->setFkLocale($locale->getIdLocale())->setName($localizedAttributes->getName())->setAttributes($encodedAttributes); $productAbstractAttributesEntity->save(); } }