@@ -63,7 +63,8 @@ class ProductFamilyController extends AdminController | |||
'choices' => array( | |||
'field.ProductFamily.behaviorCountStockOptions.' . ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE => ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE, | |||
'field.ProductFamily.behaviorCountStockOptions.' . ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY => ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY, | |||
'field.ProductFamily.behaviorCountStockOptions.' . ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT => ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT | |||
'field.ProductFamily.behaviorCountStockOptions.' . ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT => ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT, | |||
'field.ProductFamily.behaviorCountStockOptions.' . ProductFamily::BEHAVIOR_COUNT_STOCK_UNLIMITED => ProductFamily::BEHAVIOR_COUNT_STOCK_UNLIMITED | |||
), | |||
'translation_domain' => 'lcshop', | |||
'multiple' => false, |
@@ -128,11 +128,17 @@ abstract class Product extends AbstractEntity implements SortableInterface, Prod | |||
public function getAvailableQuantityInherited() | |||
{ | |||
if ($this->getProductFamily()->getBehaviorCountStock() == ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY || | |||
$this->getProductFamily()->getBehaviorCountStock() == ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE) { | |||
return $this->getProductFamily()->getAvailableQuantity(); | |||
} else if ($this->getProductFamily()->getBehaviorCountStock() == ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT) { | |||
return $this->getAvailableQuantity(); | |||
switch ($this->getProductFamily()->getBehaviorCountStock()) { | |||
case ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : | |||
case ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE : | |||
return $this->getProductFamily()->getAvailableQuantity(); | |||
break; | |||
case ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : | |||
return $this->getAvailableQuantity(); | |||
break; | |||
case ProductFamily::BEHAVIOR_COUNT_STOCK_UNLIMITED : | |||
return false; | |||
break; | |||
} | |||
} | |||
@@ -17,6 +17,7 @@ use Lc\ShopBundle\Context\ProductPropertyInterface; | |||
abstract class ProductFamily extends AbstractDocumentEntity implements ProductPropertyInterface, PriceInterface, FilterMerchantInterface | |||
{ | |||
const BEHAVIOR_COUNT_STOCK_UNLIMITED = 'unlimited' ; | |||
const BEHAVIOR_COUNT_STOCK_BY_MEASURE = 'by-measure' ; | |||
const BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY = 'by-product-family' ; | |||
const BEHAVIOR_COUNT_STOCK_BY_PRODUCT = 'by-product' ; | |||
@@ -188,18 +189,22 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr | |||
switch ($this->getBehaviorCountStock()) { | |||
case ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE : | |||
case ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : | |||
case self::BEHAVIOR_COUNT_STOCK_BY_MEASURE : | |||
case self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : | |||
$availableQuantity = $this->getAvailableQuantity() ; | |||
break; | |||
case ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : | |||
case self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : | |||
foreach($this->getProducts() as $product) { | |||
$availableQuantity += $product->getAvailableQuantityInherited() ; | |||
} | |||
break ; | |||
case self::BEHAVIOR_COUNT_STOCK_UNLIMITED : | |||
$availableQuantity = false; | |||
break; | |||
} | |||
return $availableQuantity ; |
@@ -444,7 +444,7 @@ class OrderUtils | |||
$quanityAsked = ($product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient()) * $quanityOrder; | |||
} | |||
if ($product->getAvailableQuantityInherited() >= $quanityAsked) { | |||
if ($product->getAvailableQuantityInherited() >= $quanityAsked || $product->getProductFamily()->getBehaviorCountStock() == ProductFamily::BEHAVIOR_COUNT_STOCK_UNLIMITED) { | |||
return true; | |||
} else { | |||
return false; |