Nopcommerce Product Listing Controller - nopcommerce

I am trying to do some custom programming in NopCommerce 3.50.
I have created custom filter attribute that performs required check when any controller or action method is accessed. I want to place this action filter at the place where all products are getting listed but i am not able to find any action method or controller which fetches the list of products.
Can any one let me know which controller or action method should i look for in the solution ?
Basically nop commerce follows the url rewriting with friendly names of categories i want to place my filter on that controller. so if my url is www.xyz.com/toys then i want to know to which controller this url will hit in code in order to get products of toys category ?

Nopcommerce will hit the CatalogController. And will then use the Category action method to get the products in the category Toys.
Also you should use a action filter if you are going to rewrite a action inside a nopcommerce folder.
See posts:
[https://stackoverflow.com/questions/25723821/how-to-implement-an-action-filter-in-nopcommerce]1
and
http://www.pronopcommerce.com/overriding-intercepting-nopcommerce-controllers-and-actions

Related

How can I fetch the post slugs of all languages?

I have a react project which fetches data on wordpress via api calls (plugins installed: ACF and WPML).
I have the Event CPT and viewing the page localhost: 3000 / events / first-event, I retrieve the information via the slug.
If on this page I wanted to retrieve the same event in another language, I could add the country code in the url and make a redirect.
It is possible that the same event has different slugs based on the language and the feature does not work.
Do you have any ideas on how to make this feature?
Thank you guys!
I have temporarily modified the pathname.
<a href={window.location.pathname.replace('/','/en/')}>EN</a>
I have found the solution.
I used the icl_get_languages() function to fetch the languages, icl_object_id() to retrieve the post id of a language, get_post to retrieve all fields and update_post_meta to add a custom field to the post.
Hey I have the same setting but not with React.
If you are using the API without any modifications in the class and given that the title between language is the same try the following:
/wp-json/wp/v2/posts/?post-slug=second+post&lang=fr
and page slug
/wp-json/wp/v2/pages/?page-slug=second+post&lang=fr
However, you need to modify the API response if you want your ACF fields to be there (or use a plugin).
Also mind that post ID between translations is different. Ensure to include the lang as argument in the modification of the WP_REST_Controller. https://developer.wordpress.org/reference/classes/wp_rest_controller/get_collection_params/
Let me know if that helps.

How to Create New Custom Product Details Page In NopCommerce

How to create new custom product details page in NopCommerce new generic url RouteProvice and new HTML page
Just write Generic route url in plugin and update order, give your own generic route name.
Register Generic router at DependencyRegister.
Update your controller and actionMethod for product detail page.

How to sort and display posts by selected category

I'm having a Wordpress blog system on cars. On my home page in a one div I display most recent 5 posts.
Now I want to filter these posts by user selected post category.
There is a drop down with my posts categories and user can select a category from there. Once a user select a category from there I need to show the posts which are related to that category only, without refreshing the page.
How can I achieve that?
Thanks.
You can do it in 2 steps.
On form submit you have to create an ajax request (you can do it with jQuery), this ajax request should return your filtered posts and after that you can replace your old posts with the filtered ones using .html() method as an option.
Create the function in your current WP theme functions.php, that is connected to wp_ajax_ and wp_ajax_nopriv_ action hooks. This function will receive your category ID as a $_POST parameter and will use it in WP_Query to regenerate filtered posts.
I know it is better to share the code with you, so you can find a good example here https://rudrastyh.com/wordpress/ajax-post-filters.html

how to return on product's detail page in NopCommerce 3.20

I want to create plugin which shows Category-vice MostViewed Products.
So i need to know how to return on Product's detail page from my plugin.
You should create in your plugin's controller method like Product() method in Nop.Web\Controllers\CatalogController.cs which method, that will return your new views or default views from Nop.Web.

URL Conflict between custom post type, page and post

I created a custom post type 'abcd',when I create a corresponding post "test", url says
mysite.com/abcd/test/
Now I created a page which will display all custom posts of type 'abcd'. I need the url of this page to look like
mysite.com/abcd
How to do so?
Also lets say i create a post with similar url mysite.com/abcd, Now when i try to open this url, technically what should be displayed?
This is quickly going to become a nightmare of rewrite rules. I'd suggest re-thinking your approach here. I'm working on something similar right now, and what I've done is this:
Created a custom post type called Games (set singular to game)
Created a page called Schedule, and made a template that is essentially an archive of the Games post type
Set Schedule URL to /schedule/, and game schedule to /game/
So now if a user wants to view the schedule, they go /schedule/ and see a list of games. If they click a game, the URL will look something like /game/month-day-opponentCity-opponentTeam/

Resources