Skip to content

No Newsletter subscription in Excel export #7409

@AHoxha19

Description

@AHoxha19

nopCommerce version: 4.50.1

Steps to reproduce the problem: Export all customers to excel in the admin area.

I need to have the clients subscribed to a store in the excel exported file. It is strange that this is present in the xml version but on the excel one.

I changed the source code by adding this function in ExportManager.cs (inside Nop.Services library):

async Task<object> getNewsLetterSubscription(Customer customer)
            {
                var stores = await _storeService.GetAllStoresAsync();

                var subscriptions = "";

                foreach(var store in stores)
                {
                    var newsletter = await _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreIdAsync(customer.Email, stores.First().Id);
                    var subscribedToNewsletters = newsletter != null && newsletter.Active;

                    if(!string.IsNullOrWhiteSpace(subscriptions))
                    {
                        subscriptions += "; ";
                    }

                    subscriptions += $"{store.Name} - {subscribedToNewsletters}";
                }
                return subscriptions;
            }

And the new property:

new PropertyByName<Customer>("NewsletterSubscription", getNewsLetterSubscription)

All stores are represented with a True False on one column instead of a separate column for each store. This is a temp fix but we should have the same behavior as the xml file. Is it possible ?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions