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 · 3 comments
Open

No Newsletter subscription in Excel export #7409

AHoxha19 opened this issue Nov 12, 2024 · 3 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 ?

@aniket-sainii
Copy link

aniket-sainii commented Jan 8, 2025

Hi @AndreiMaz, @AHoxha19
I’m currently working on implementing the functionality for exporting newsletter subscription details in the customer data export. I wanted to clarify how you would like the data to be presented:
Should the newsletter subscription status be included in separate columns for each store like XML (e.g., Newsletter-Store1, Newsletter-Store2, etc.)?
Please let me know your preference, and I’ll adjust the implementation accordingly.
Looking forward to your feedback!

@AHoxha19
Copy link
Author

AHoxha19 commented Jan 9, 2025

Hi @aniket-sainii, i think that it should have the same structure as the XML file, each store as a column.

@aniket-sainii
Copy link

aniket-sainii commented Jan 9, 2025

Hi @AHoxha19
This pull request (Add newsletter subscription data to Excel export #7488) addresses the issue by including the newsletter subscription status for each store in the Excel export of customer data.

Key changes include:

  1. Fetching all stores using ( _storeService.GetAllStoresAsync )
  2. Dynamically fetching the subscription data for each store using
    ( _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreIdAsync )
  3. Adding the subscription status as a new column in the Excel export.

For further details, you can review the pull request linked above.
Customers Excel report.xlsx
Please see the attached sample Excel file for a demonstration.

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

4 participants