3.0 Admin > Edit a Product > Pictures > Delete throws 500.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
10 years ago
I did some research and there's a small bug when deleting Product pictures.

ProductController.cs (line 1,750)

        [GridAction(EnableCustomBinding = true)]
        public ActionResult ProductPictureDelete(int id, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
                return AccessDeniedView();

            var productPicture = _productService.GetProductPictureById(id);
            if (productPicture == null)
                throw new ArgumentException("No product picture found with the specified id");

            var productId = productPicture.ProductId;

            //a vendor should have access only to his products
            if (_workContext.CurrentVendor != null)
            {
                var product = _productService.GetProductById(productId);
                if (product != null && product.VendorId != _workContext.CurrentVendor.Id)
                {
                    return Content("This is not your product");
                }
            }

            _productService.DeleteProductPicture(productPicture);
            var picture = _pictureService.GetPictureById(productId); // <---------- Should be pictureId
            _pictureService.DeletePicture(picture);
            
            return ProductPictureList(command, productId);
        }


So, I changed it to

            int pictureId = productPicture.Id;
            _productService.DeleteProductPicture(productPicture);
            var picture = _pictureService.GetPictureById(pictureId);
            _pictureService.DeletePicture(picture);


I've changed it on my code.

Out of curiosity, when should I pull the latest code from the repo?

-D
10 years ago
Whoops...

int pictureId = productPicture.PictureId;

-D
10 years ago
Fixed. Thanks a lot!

I think the official release should be also updated because such issue should not wait until the next version is released
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.