Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

32 linhas
1.1KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Factory\Product;
  3. use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
  4. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  5. use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
  6. use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
  7. use Lc\SovBundle\Factory\AbstractFactory;
  8. class ProductFamilyFactory extends AbstractFactory
  9. {
  10. public function create(MerchantInterface $merchant): ProductFamilyInterface
  11. {
  12. $class = ProductFamilyContainer::getEntityFqcn();
  13. $productFamily = new $class;
  14. $productFamily->setBehaviorAddToCart(ProductFamilyModel::BEHAVIOR_ADD_TO_CART_SIMPLE);
  15. $productFamily->setSaleStatus(true);
  16. $productFamily->setStatus(1);
  17. $productFamilySectionPropertyFactory = new ProductFamilySectionPropertyFactory();
  18. foreach($merchant->getSections() as $section) {
  19. $productFamilySectionProperty = $productFamilySectionPropertyFactory->create($section, $productFamily);
  20. $productFamily->addProductFamilySectionProperty($productFamilySectionProperty);
  21. }
  22. return $productFamily;
  23. }
  24. }