Put a product collection on just one page?

4 years ago
#12828 Quote
  • 1
Is there any way to put a product collection on just one specific page? (topic)

4 years ago
#12832 Quote
  • Moderator
  • 277

You can put a product collection on a specific topic page but that requires a bit of code modifications.

You will need to add a custom widget zone that will be set to display the product collections on your topic page.
To add a widget zone you will firstly need to go to Plugins\SevenSpikes.Nop.Plugins.SmartProductCollections\SupportedWidgetZones.xml. You will need to add your widget zone there.

After that you will need to go to Views\Topic\TopicDetails.cshtml and add your widget zone by placing the following line of code wherever you want the product collections to appear:

After that you will simply need to create a product collection and select the widget zone you created.
This will, however, display the product collections on all of the topic pages. In order to display it on only one topic page you will need to write some code that will check if you are on the correct topic page. It should be something like that :

@if (Model.SystemName.Equals("YourTopicName"))

Note: I need to warn you that there are complications that come with modifying the nopCommerce code. During updates, you will need to merge all your changes with the files of the new version of nopCommerce. Also, our support can`t help you with problems that occurred because of modification or customization of the source code.
Anton Ivanov
6 days ago
#21694 Quote
  • 1
Really can't get this to work getting the following error:

An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.

'IHtmlHelper<TopicModel>' does not contain a definition for 'Widget' and no extension method 'Widget' accepting a first argument of type 'IHtmlHelper<TopicModel>' could be found (are you missing a using directive or an assembly reference?)

I've copied the above exactly and inserted the correct names. What could be the error?