Skip to content

Commit

Permalink
allow to remove attribute during update product.
Browse files Browse the repository at this point in the history
  • Loading branch information
indpurvesh committed Mar 24, 2017
1 parent 1e202d2 commit 4f6b033
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions modules/base/Mage2/Catalog/Helpers/ProductHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,16 @@ public function saveProductAttribute($product, ProductRequest $request)
}
}

foreach(array_flip($existingIds) as $id) {
ProductVariation::destroy($id);
if(count($existingIds)>0) {
foreach (array_flip($existingIds) as $id) {
ProductVariation::destroy($id);
}
}

} else {


//only needed when remove all attribute using remove icon during edit product
$product->update(['has_variation' => 0]);
}


Expand Down
2 changes: 1 addition & 1 deletion modules/base/Mage2/Catalog/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getAssignedAttributes() {
return $productVariationsList->unique('product_attribute_id');
}

return null;
return [];

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<?php
$attributes = $product->getAssignedAttributes();
//todo How does multiple Variation works
//$firstVariation = $product->productVariations()->get()->first();
//$attribute = $firstVariation->productAttribute;
Expand Down

0 comments on commit 4f6b033

Please sign in to comment.