Browse Source

ProductFamilySolver

packProduct
Guillaume 3 years ago
parent
commit
4416a636eb
1 changed files with 42 additions and 27 deletions
  1. +42
    -27
      Solver/Product/ProductFamilySolver.php

+ 42
- 27
Solver/Product/ProductFamilySolver.php View File

public function getBehaviorCountStockChoices(): array public function getBehaviorCountStockChoices(): array
{ {
return [ return [
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE,
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT,
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY,
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE,
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT,
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY,
]; ];
} }


public function getWaringMessageTypeChoices(): array public function getWaringMessageTypeChoices(): array
{ {
return [ return [
ProductFamilyModel::WARNING_MESSAGE_TYPE_ERROR,
ProductFamilyModel::WARNING_MESSAGE_TYPE_INFO,
ProductFamilyModel::WARNING_MESSAGE_TYPE_SUCCESS,
ProductFamilyModel::WARNING_MESSAGE_TYPE_WARNING,
ProductFamilyModel::WARNING_MESSAGE_TYPE_ERROR,
ProductFamilyModel::WARNING_MESSAGE_TYPE_INFO,
ProductFamilyModel::WARNING_MESSAGE_TYPE_SUCCESS,
ProductFamilyModel::WARNING_MESSAGE_TYPE_WARNING,
]; ];
} }


public function getBehaviorAddToCartChoices(): array public function getBehaviorAddToCartChoices(): array
{ {
return [ return [
ProductFamilyModel::BEHAVIOR_ADD_TO_CART_MULTIPLE,
ProductFamilyModel::BEHAVIOR_ADD_TO_CART_SIMPLE,
ProductFamilyModel::BEHAVIOR_ADD_TO_CART_MULTIPLE,
ProductFamilyModel::BEHAVIOR_ADD_TO_CART_SIMPLE,
]; ];
} }


public function getBehaviorPriceChoices(): array public function getBehaviorPriceChoices(): array
{ {
return [ return [
ProductFamilyModel::BEHAVIOR_PRICE_BY_PIECE,
ProductFamilyModel::BEHAVIOR_PRICE_BY_REFERENCE_UNIT,
ProductFamilyModel::BEHAVIOR_PRICE_BY_PIECE,
ProductFamilyModel::BEHAVIOR_PRICE_BY_REFERENCE_UNIT,
]; ];
} }


public function getTypeExpirationDateChoices(): array public function getTypeExpirationDateChoices(): array
{ {
return [ return [
ProductFamilyModel::TYPE_EXPIRATION_DATE_DLC,
ProductFamilyModel::TYPE_EXPIRATION_DATE_DDM,
ProductFamilyModel::TYPE_EXPIRATION_DATE_DLUO,
ProductFamilyModel::TYPE_EXPIRATION_DATE_DLC,
ProductFamilyModel::TYPE_EXPIRATION_DATE_DDM,
ProductFamilyModel::TYPE_EXPIRATION_DATE_DLUO,
]; ];
} }


public function getBehaviorExpirationDateChoices(): array public function getBehaviorExpirationDateChoices(): array
{ {
return [ return [
ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY,
ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT,
ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY,
ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT,
]; ];
} }


public function getBehaviorDisplaySaleChoices(): array public function getBehaviorDisplaySaleChoices(): array
{ {
return [ return [
ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE,
ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_QUANTITY,
ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE,
ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_QUANTITY,
]; ];
} }




public function getTaxRateInherited(ProductPropertyInterface $productFamily) public function getTaxRateInherited(ProductPropertyInterface $productFamily)
{ {
if($productFamily instanceof ProductInterface) {
if ($productFamily instanceof ProductInterface) {
$productFamily = $productFamily->getProductFamily(); $productFamily = $productFamily->getProductFamily();
} }


$arrayCountProducts[$titleProduct] = []; $arrayCountProducts[$titleProduct] = [];
} }


if (!in_array($this->productSolver->getQuantityLabelInherited($product), $arrayCountProducts[$titleProduct])) {
if (!in_array(
$this->productSolver->getQuantityLabelInherited($product),
$arrayCountProducts[$titleProduct]
)) {
$arrayCountProducts[$titleProduct][] = $this->productSolver->getQuantityLabelInherited($product); $arrayCountProducts[$titleProduct][] = $this->productSolver->getQuantityLabelInherited($product);
} }


} }
} }


public function getBehaviorPriceInherited(ProductFamilyInterface $productFamily) :string
public function getBehaviorPriceInherited(ProductFamilyInterface $productFamily): string
{ {
return $productFamily->getBehaviorPrice(); return $productFamily->getBehaviorPrice();
} }
{ {
$qualityLabelArray = $productFamily->getQualityLabels(); $qualityLabelArray = $productFamily->getQualityLabels();


foreach($qualityLabelArray as $qualityLabel) {
if(in_array($qualityLabel->getDevAlias(), $labelArray)) {
foreach ($qualityLabelArray as $qualityLabel) {
if (in_array($qualityLabel->getDevAlias(), $labelArray)) {
return $qualityLabel; return $qualityLabel;
} }
} }
{ {
$qualityLabelArray = $productFamily->getQualityLabels(); $qualityLabelArray = $productFamily->getQualityLabels();


foreach($qualityLabelArray as $qualityLabel) {
if(in_array($qualityLabel->getDevAlias(), $labelArray)) {
foreach ($qualityLabelArray as $qualityLabel) {
if (in_array($qualityLabel->getDevAlias(), $labelArray)) {
return true; return true;
} }
} }


public function getSection(ProductFamilyInterface $productFamily): ?SectionInterface public function getSection(ProductFamilyInterface $productFamily): ?SectionInterface
{ {
foreach($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) {
if($productFamilySectionProperty->getStatus()) {
foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) {
if ($productFamilySectionProperty->getStatus()) {
return $productFamilySectionProperty->getSection(); return $productFamilySectionProperty->getSection();
} }
} }


return null; return null;
} }

public function isInSection(ProductFamilyInterface $productFamily, SectionInterface $section): bool
{
foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) {
if ($productFamilySectionProperty->getSection()->getId() == $section->getId(
) && $productFamilySectionProperty->getStatus()) {
return true;
}
}

return false;
}
} }



Loading…
Cancel
Save