Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Newsletter subscription in Excel export #7409

Open
AHoxha19 opened this issue Nov 12, 2024 · 0 comments
Open

No Newsletter subscription in Excel export #7409

AHoxha19 opened this issue Nov 12, 2024 · 0 comments

Comments

@AHoxha19
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants