Không xóa được sub ảnh trong product/ sản phẩm
ThanhNguyenDo opened this issue · comments
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
- Go to 'Admin\Sản phẩm'
- Vào edit 1 sản phẩm để xoá hết ảnh phụ
- Submit
- Nếu xoá hết sub ảnh sẽ k update được, luôn phải để lại 2 ảnh, 1 ảnh chính và 1 ảnh phụ
Expected behavior
Cho phép xoá hết ảnh phụ
Root cause analysis
//Update sub mages
AdminProductController
if ($subImages && in_array($product['kind'], [SC_PRODUCT_SINGLE, SC_PRODUCT_BUILD])) {
$product->images()->delete();
$arrSubImages = [];
foreach ($subImages as $key => $image) {
if ($image) {
$arrSubImages[] = new ShopProductImage(['image' => $image]);
}
}
$product->images()->saveMany($arrSubImages);
}
Khi $subImages length = 0 thì sẽ không vào được block if này
@ThanhNguyenDo
Fixed s-cart/core@c451870
Pls run php composer.phar update s-cart/core
Thanks.