public function __toString() { $stringOutput = $this->product->getName(); foreach ($this->variationAttributes as $attr) { $stringOutput .= ' ' . $attr->getProductAttribute()->getAttributeName() . ' : ' . $attr->getAttributeValue(); } return $stringOutput; }
private function generateVariations() { $agregatedAttributes = $this->separateByProductAttribute(); foreach ($agregatedAttributes as $aggregationOfAttributes) { $variation = new \Hypersites\StockBundle\Entity\ProductVariation(); $variation->setMaxCost($this->parentProduct->getMaxCost())->setMinCost($this->parentProduct->getMinCost())->setProduct($this->parentProduct)->setQtyStock(0); if (is_array($aggregationOfAttributes)) { foreach ($aggregationOfAttributes as $attribute) { $variation->addVariationAttributes($attribute); $attribute->addProductVariation($variation); $this->em->persist($attribute); } } else { $variation->addVariationAttributes($aggregationOfAttributes); $attribute->addProductVariation($variation); $this->em->persist($aggregationOfAttributes); } $this->em->persist($variation); $this->em->persist($this->parentProduct); } $this->em->flush(); }
public function getPossibleVariationsForProduct(Product $product) { $attributes = $product->getAttributes(); $this->createQueryBuilder($alias); }