/** * @param Product $product * @return void */ private function saveAttributes(Product $product) { if ($product->isAttributesModified()) { $this->getDb()->query("DELETE FROM product_attribute WHERE product_id = :productId", [':productId' => $product->getId()]); foreach ($product->getAttributes() as $attribute) { if ($attribute['attribute_id']) { $this->getDb()->query("DELETE FROM product_attribute WHERE product_id = :productId AND attribute_id = :attributeId", [':productId' => $product->getId(), ':attributeId' => $attribute['attribute_id']]); foreach ($attribute['product_attribute_description'] as $language_id => $product_attribute_description) { $this->getDb()->query("\n INSERT INTO product_attribute\n SET\n product_id = :productId,\n attribute_id = :attributeId,\n language_id = :languageId,\n `text` = :text\n ", [':productId' => $product->getId(), ':attributeId' => $attribute['attribute_id'], ':languageId' => $language_id, ':text' => $product_attribute_description['text']]); } } } } }