Multi Store Support fro Nop 2.0

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
i'm working on the check out, hope to finish soon.
on my next upload i will show some features for the store front.

basically if u want to show just the one store product send the store id to the searchproduct method. at the moment it gets storeid = 1 which retrieve all product from all stores
12 years ago
Thank you so much.  I will give it a try.
12 years ago
HI Hezyz,
I successfully got the store to show only the products of selected store by hardcode the storeid in the ProductService.cs file.  Is there anyway to pass this storeid in the url or something to change the storeid on the fly?  Please advice.  Also, I couldn't get the front page feature products to show only feature products of selected store?  Where do I miss?

Thanks a lot.
Tram
12 years ago
sorry I meant I found hardcoded storeid in CatalogController.cs file, not ProductService.cs file.
12 years ago
you can pass the storeId  www.domain.com?store=2
save it with request.querystring
add to the WorkContext new field - >Store  workingStore and save the storeId u have passed.
then change all the searchProduct methods and use the _workContext.workingStore instead of the 1 for the storeId

The home page products, another method i forgot to deal with.
home page products is not using the searchProduct method, it had its own method GetAllProductsDisplayedOnHomePage
U need to pass a storeId to that method:(I did not try it, but I think it will do the job)

public virtual IList<Product> GetAllProductsDisplayedOnHomePage(int storeId)
        {
            var query = from p in _productRepository.Table
                        orderby p.Name
                        where p.Published &&
                        !p.Deleted &&
                        p.ShowOnHomePage
                        select p;
            //ada by hz
            //store filtering
            if (storeId > 1)
            {
                query = from p in query
                        where (p.StoreId == storeId)
                        select p;
            }
            //end by hz
            var products = query.ToList();
            return products;
        }
12 years ago
Thanks a lot.  I will give it a try.
Tram
12 years ago
It works for me hezyz.  I can get all the items based on the store number that get passed in the querystring.  However, if I click on something, the "?store=2" disappears and the querystring and the system will get all items in all stores.  How can I make the querystring sticks in the url.

When do you think you have the front end and payment piece available? :)

Thanks.
Tram
12 years ago
you have to add your workingstore to the system. take the working language for example and follow it. do the same to the new field workingstore.

then look for all the methods that get the products like searchproduct and pass the parameter storeid which is workingstore.
I'm planning to do that, however it might take me a while.
12 years ago
I did add workingstore to WorkContext and set it with the querystring "store" value.  And all of my searchproduct procedures in CatalogController.cs has parameter _workcontext.workingstore pass in.  However, This only works when I have querystring store=xxx in the url like this http://localhost:63988/productag/11/jewelry?store=2.  If I click on any link in the system, the ?store=2 is dropped.  Does the system suppose to remember store=2?  

Am I still missing something else?

Tram
12 years ago
Hello,

I tried running the installation for the multistore buy I keep get the error below, any ideas?

Thanks,

Zugo




Setup failed: System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "Customer_Store". The conflict occurred in database "MyStore", table "dbo.Store", column 'Id'. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues) at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) --- End of inner exception stack trace --- at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) at System.Data.Entity.Internal.InternalContext.SaveChanges() --- End of inner exception stack trace --- at System.Data.Entity.Internal.InternalContext.SaveChanges() at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() at System.Data.Entity.DbContext.SaveChanges() at Nop.Data.EfRepository`1.Insert(T entity) in C:\Web Sites\NopCommerce_2_MultiStore\Libraries\Nop.Data\EfRepository.cs:line 37 at Nop.Services.Installation.InstallationService.InstallCustomersAndUsers(String defaultUserEmail, String defaultUserPassword) in C:\Web Sites\NopCommerce_2_MultiStoreNoData\Libraries\Nop.Services\Installation\InstallationService.cs:line 4042 at Nop.Services.Installation.InstallationService.InstallData(String defaultUserEmail, String defaultUserPassword, Boolean installSampleData) in C:\Web Sites\NopCommerce_2_MultiStoreNoData\Libraries\Nop.Services\Installation\InstallationService.cs:line 9192 at Nop.Web.Controllers.InstallController.Index(InstallModel model) in C:\Web Sites\NopCommerce_2_MultiStoreNoData\Presentation\Nop.Web\Controllers\InstallController.cs:line 378
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.