您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

32 行
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. }