Cosmetic fix (bug) - Copy product doesn't copy product's ACL

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 1 an
When nopcommerce copies the product then nopcommerce doesn't copy ACL.

Add this code in the method
        public virtual async Task<Product> CopyProductAsync(Product product, string newName,
            bool isPublished = true, bool copyImages = true, bool copyAssociatedProducts = true)

Old code
            //store mapping
            var selectedStoreIds = await _storeMappingService.GetStoresIdsWithAccessAsync(product);
            foreach (var id in selectedStoreIds)
                await _storeMappingService.InsertStoreMappingAsync(productCopy, id);

            //tier prices
            await CopyTierPricesAsync(product, productCopy);


New code

            //store mapping
            var selectedStoreIds = await _storeMappingService.GetStoresIdsWithAccessAsync(product);
            foreach (var id in selectedStoreIds)
                await _storeMappingService.InsertStoreMappingAsync(productCopy, id);
                //customer role mapping
                var customerRoleIds = await _aclService.GetCustomerRoleIdsWithAccessAsync(product);
                foreach (var id in customerRoleIds)
                    await _aclService.InsertAclRecordAsync(productCopy, id);

            //tier prices
            await CopyTierPricesAsync(product, productCopy);


and add this code in the method
protected virtual async Task<Product> CopyBaseProductDataAsync(Product product, string newName, bool isPublished)

old code
                MetaTitle = product.MetaTitle,
                AllowCustomerReviews = product.AllowCustomerReviews,
                LimitedToStores = product.LimitedToStores,
                Sku = newSku,
                ManufacturerPartNumber = product.ManufacturerPartNumber,
                Gtin = product.Gtin,


new code

                MetaTitle = product.MetaTitle,
                AllowCustomerReviews = product.AllowCustomerReviews,
                LimitedToStores = product.LimitedToStores,
                SubjectToAcl = product.SubjectToAcl,
                Sku = newSku,
                ManufacturerPartNumber = product.ManufacturerPartNumber,
                Gtin = product.Gtin,
Il y a 1 an
Thanks a lot, Alex! Here is a work item
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.