| @@ -666,72 +666,4 @@ class Product extends AbstractEntity { | |||
| return $this->warranty != $product->getPrevWarranty(); | |||
| } | |||
| /** | |||
| * ON manual product save form submit | |||
| */ | |||
| public function hasChanges(Product $previousProductState): bool { | |||
| $fabricNameChange = $this->isProductFabricNameStateChanged($previousProductState); | |||
| $eolChange = $this->isProductEolStateChanged($previousProductState); | |||
| $descriptionChange = $this->isProductDescriptionStateChanged($previousProductState); | |||
| $notesChangeChange = $this->isProductNotesStateChanged($previousProductState); | |||
| $warrantyChange = $this->isProductWarrantyChanged($previousProductState); | |||
| $axicoNameChange = $this->isProductAxicoNameChanged($previousProductState); | |||
| return $fabricNameChange || $eolChange || $descriptionChange || $notesChangeChange || $warrantyChange || $axicoNameChange; | |||
| } | |||
| public function isProductFabricNameStateChanged(Product $product): bool { | |||
| if ($product->getFabricName()) { | |||
| return strpos( | |||
| strtolower($this->fabricName), | |||
| strtolower($product->getFabricName()) | |||
| ) !== false; | |||
| } | |||
| return false; | |||
| } | |||
| public function isProductEolStateChanged(Product $product): bool { | |||
| if ($product->getEol()) { | |||
| return strpos( | |||
| strtolower($this->eol), | |||
| strtolower($product->getEol()) | |||
| ) !== false; | |||
| } | |||
| return false; | |||
| } | |||
| public function isProductDescriptionStateChanged(Product $product): bool { | |||
| if ($product->getDescription()) { | |||
| return strpos( | |||
| strtolower($this->description), | |||
| strtolower($product->getDescription()) | |||
| ) !== false; | |||
| }return false; | |||
| } | |||
| public function isProductNotesStateChanged(Product $product): bool { | |||
| if ($product->getNotes()) { | |||
| return strpos( | |||
| strtolower($this->notes), | |||
| strtolower($product->getNotes()) | |||
| ) !== false; | |||
| } | |||
| return false; | |||
| } | |||
| public function isProductAxicoNameStateChanged(Product $product): bool { | |||
| if ($product->getAxicoName()) { | |||
| return strpos( | |||
| strtolower($this->axicoName), | |||
| strtolower($product->getAxicoName()) | |||
| ) !== false; | |||
| } | |||
| return false; | |||
| } | |||
| public function isProductWarrantyStateChanged(Product $product): bool { | |||
| return $this->warranty != $product->getWarranty(); | |||
| } | |||
| } | |||
| @@ -312,7 +312,7 @@ class ProductAdd extends ArlistaAbstractForm { | |||
| /* @var $product Product */ | |||
| $product = $this->getProductFactory()->create(); | |||
| $product->setName($values['name']); | |||
| $product->setfabricName($values['fabric_name'] ? $values['fabric_name'] : $values['name']); | |||
| $product->setFabricName($values['fabric_name'] ? $values['fabric_name'] : $values['name']); | |||
| $product->setAxicoName($values['axico_name'] ? $values['axico_name'] : $values['name']); | |||
| $product->setSif($values['sif'] ? $values['sif'] : 0); | |||
| $product->setFabricId($values['fabricId']); | |||
| @@ -469,11 +469,10 @@ class ProductUploadedEdit extends ArlistaAbstractForm { | |||
| $values = $form_state->getValues(); | |||
| $product = $this->getProductFactory()->find($values['id']); | |||
| $previousProductState = $product; | |||
| $previousPrice = $product->getPrice(); | |||
| $product->setName($values['name']); | |||
| $product->setfabricName($values['fabric_name'] ? $values['fabric_name'] : $values['name']); | |||
| $product->setFabricName($values['fabric_name'] ? $values['fabric_name'] : $values['name']); | |||
| $product->setAxicoName($values['axico_name'] ? $values['axico_name'] : $values['name']); | |||
| $product->setSif($values['sif'] ? $values['sif'] : 0); | |||
| $product->setFabricId($values['fabricId']); | |||
| @@ -507,7 +506,7 @@ class ProductUploadedEdit extends ArlistaAbstractForm { | |||
| $product->setListed($values['listable']); | |||
| $product->setPriceDevDTwo($values['price_dev_d_two'] ? $values['price_dev_d_two'] : 0.000); | |||
| if($previousPrice !== $product->getPrice()){ | |||
| if($previousPrice != $product->getPrice()){ | |||
| if ($product->isComponentBased()) { | |||
| $component = $this->getComponentFactory()->find($product->getParentComponentId()); | |||
| $calculation = $this->getCalculationFactory()->findByComponent($component); | |||
| @@ -521,12 +520,10 @@ class ProductUploadedEdit extends ArlistaAbstractForm { | |||
| $product->setCalculation($calculation); | |||
| $product->calculatePrices(); | |||
| } | |||
| if($product->hasChanges($previousProductState)){ | |||
| $product->setCorrectStatus(Status::FRISSITENDO); | |||
| } | |||
| $product = $this->getProductFactory()->save($product); | |||
| $this->getCacheService()->resetCache([$this->getFormId(), $this->source, $product->getId()]); | |||