Skip to content

Commit

Permalink
fix fatal on null if orphan feature (#30)
Browse files Browse the repository at this point in the history
* fix fatal on null if orphan feature

* remove false values from feature array

* update version number

Co-authored-by: Cédric Robert <crobert@openstudio.fr>
  • Loading branch information
crobert and Cédric Robert authored May 3, 2021
1 parent c409beb commit ba2355f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.0.13</version>
<version>1.0.14</version>
<authors>
<author>
<name>Vincent Lopes-Vicente</name>
Expand Down
36 changes: 21 additions & 15 deletions Model/Api/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,27 @@ public function createFromTheliaModel($theliaModel, $locale = null)
parent::createFromTheliaModel($theliaModel, $locale);

$modelFactory = $this->modelFactory;
$this->features = array_map(
function (FeatureProduct $featureProduct) use ($modelFactory){
$propelFeature = $featureProduct->getFeature();

if (null !== $featureProduct->getFeatureAv()) {
// Temporary set only product feature av to build good feature av list
$propelFeature->addFeatureAv($featureProduct->getFeatureAv());
}

$feature = $modelFactory->buildModel('Feature', $propelFeature);

$propelFeature->clearFeatureAvs();
return $feature;
},
iterator_to_array($theliaModel->getFeatureProducts())
$this->features = array_filter(
array_map(
function (FeatureProduct $featureProduct) use ($modelFactory){
$propelFeature = $featureProduct->getFeature();
if(null === $propelFeature){
return false;
}
if (null !== $featureProduct->getFeatureAv()) {
// Temporary set only product feature av to build good feature av list
$propelFeature->addFeatureAv($featureProduct->getFeatureAv());
}
$feature = $modelFactory->buildModel('Feature', $propelFeature);

$propelFeature->clearFeatureAvs();
return $feature;
},
iterator_to_array($theliaModel->getFeatureProducts())
),
function($value){
return $value;
}
);

$this->categories = array_map(
Expand Down

0 comments on commit ba2355f

Please sign in to comment.