|
12345678910111213141516171819202122232425262728293031 |
- <?php
-
- namespace Lc\CaracoleBundle\Factory\Product;
-
- use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
- use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
- use Lc\SovBundle\Factory\AbstractFactory;
-
- class ProductFamilyFactory extends AbstractFactory
- {
- public function create(MerchantInterface $merchant): ProductFamilyInterface
- {
- $class = ProductFamilyContainer::getEntityFqcn();
- $productFamily = new $class;
-
- $productFamily->setBehaviorAddToCart(ProductFamilyModel::BEHAVIOR_ADD_TO_CART_SIMPLE);
- $productFamily->setSaleStatus(true);
- $productFamily->setStatus(1);
-
- $productFamilySectionPropertyFactory = new ProductFamilySectionPropertyFactory();
-
- foreach($merchant->getSections() as $section) {
- $productFamilySectionProperty = $productFamilySectionPropertyFactory->create($section, $productFamily);
- $productFamily->addProductFamilySectionProperty($productFamilySectionProperty);
- }
-
- return $productFamily;
- }
- }
|