Let's take a look at Entities within the Miva Merchant Template Language. An Entity is part of the Miva Merchant vocabulary. It represents a variable. Now we’ve already seen this a little bit within the previous videos. They always start with &mvt: and they end with a semicolon. There's different types. There’s global and there’s local, but they all follow the same syntax. However, an entity is a special type of variable. It can only be used to output a value to the page. With any other variable, usually you can modify it. You can change its value, you can concatenate it, you can do different things to change its output. Where an entity represents the value of that variable anytime you want to output it to the page. Entities can also be encoded and we’ll dive into this in the next video in-depth. However, there are three different encoding types that can be used to output an entity.
Entities cannot be used in Expressions. So if the product code equals this, then do this. In order to do that you need a variable. In a variable in an entity always contain the same value, but one is used for the output to the screen, the other is using conditions. And let me just add, an entity and a variable will always contain the same value. Let's take a look at some examples to see this in action. So here I am over in my text editor. I have an entity here &mvt:product:code:;. Now this is a structure which contains the product code. So if I wanted to output the product code to the page, I would use this entity and I can use it anywhere within the page and everywhere it's used it will print the product code. Now what's the variable for that same product code? Well it's going to the structure that references that variable, so it's l.settings:product:code and again both these contain the same value, but one is used for conditional statements and the other one is used to output the value to the page. Here's an example: so here I have an “if” statement. “If” and then we’re printing the entitiy for the product code, “if expr=’&mvt:product:code; EQ ‘test’” well, because Entities cannot be used in conditional statements, this will not work. You’ll actually get a compile error if you tried to take this code and update it within Miva. In order to do this correctly you have to use the variable l.settings:product:code and that can be used within conditional statements. Here's one more example. So say I wanted to output the text “Welcome to” and the name of my store; well there's an entity for “store name,” it's &mvt:store:name; and this will output my store name to the page. However, the opposite to that is if I try to take l.seettings:store:name; and output that to the page. This will not work. This will not print any value to the page, because this the variable and this is an entity. The key thing to remember with entities is that they're only used to output values to the page.