24/7 Support: 800.608.6482


Developer Videos

Videos | Understanding merchant.mvc

ver. 9.0 and later

Video Transcript

One common area of confusion when learning Miva Merchant and learning how to develop stores with Miva Merchant has to do with Miva Merchant’s default url. This is domain.com/mm5/merchant.mvc. Now we’re going to get into the MM5 part later, so just ignore that part for now. What I want to focus on is the merchant.mvc and what it does. Now, from an earlier video, extension .mvc is just a compiled Miva script file. So that’s all it is. A compiled Miva script file called Merchant. You should think of this as Miva’s index page. If you’re familiar with Wordpress, it has index.php, or a regular web site usually has index.html as a page that first loads when you come to the front of the web site. Merchant.mvc is Miva’s version of that page. It’s a controller page. All it does is read in the parameters and it calls out the right functions to process the request and do what you told it to do. You can almost think of it like an air traffic controller. It’s taking incoming requests, and directing them out to the pieces of software to actually handle that request.

Because it’s Miva’s default page, it does things like create the database connection, loads all the configuration to make the store work, it selects the store in the case we have multiple stores or a mall set up. It does things like error checking, so does the store exist, is this the right store code, all that’s part of the merchant.mvc file. Then one step further if it’s your first time visiting the site it has the logic to create the basket. It will execute actions, which we’ve talked about previously. Such things as adding things to the cart, or moving the product, or updating the quantity, or logging in or logging out. A lot of that logic is located in .mvc. Now, in the url you pass it a screen code. So the screen code of SFNT means it’s the storefront. It will go out and grab and render that page and return it back to the browser. The last thing that is does has to do with maintenance mode and ui exceptions. So it has all the logic for maintenance mode where you put it in maintenance mode so the visitors can’t see anything and user interface errors and exceptions. All this is handled in the merchant.mvc file. You the developer really tell it what to do depending on what parameters you pass before the url. So the store code, the screen, the product code, the category code, the action - all that’s passed either as a get or a post to merchant.mvc. It processes those requests, goes out and executes the right code to make it all work.

If you’re ever interested in digging into the source code of the merchant.mvc, the full file is actually available in Miva Merchant’s limited source kit. You can download it for free on our web site and it will contain the uncompiled source code, the merchant.mv file. I actually have a copy of it here and I want to show you a couple of things. So here is the file merchant.mv. Now, I have it all collapsed so all you can see is the function names, but this is enough to illustrate the concept of what it does. So at the very beginning it loads this config.mvc. This file contains all of the Miva Merchant configurations, all the database configuration, everything you need for Miva Merchant to run. Merchant is the main function that’s called when this file runs. It does a lot of the setup for things like selecting the right store, session ids, things like that. Merchant actions is a function that contains all the logic to determine what actions were submitted and execute those actions. Merchant Screens determines what screen or what page needs to be rendered, goes out, grabs that page, pulls it back in and displays it in the browser.

These next three have to do with maintenance mode. So, when the store’s closed, when to disallow new baskets and the error to display when the store is closed. So this is pretty much it, the entire file. Now these are just the functions, there’s actually a lot more source code than this. But this is all that file does. If I scroll down there’s actually a few more functions which actually define the actions such as “Add product to cart.” This logic to add product to basket is actually located in the merchant.mvc file. The main reason I want to talk about this file is so you can understand what it does and how its used. This file is the brain of Miva Merchant. It handles all requests, which is why you see it in every single url.

Looking for Developer Docs?

We have a whole section for that, including: Developer Training Series, Template Language docs, Module Development tutorials and much, much more.

Head to the Developer Section

This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.


Copyright © 1997 – 2024 Miva®, Miva Merchant®, MivaPay®, MivaCon®, Camp Miva®, Miva Connect®, Miva, Inc. All Rights Reserved.