The technical term given in many articles for this is Template Variables. I am trying to understand how we can find the variable name given in the controller for a specific field of Shopware 5 front end (ex. Product Name)
For example, I can see the template variable for article name has been given as $sArticle.articleName. I found this when I checked the source code manually.
Let’s say I want to find the discount value given for particular product, How can I print this on my theme? What variable I should use and what is the easy way to find it.
I can assign values from back end for all the variables but my question is how I can access them on my theme file when I update my theme when it comes to technical development side.
Please Note: I am trying to understand the shopware5 technical side.
Using the {debug} function will usually give you a list of all assigned variables. This list should also include a variable $Controller which will give you a hint to the currently related Controller.
Unfortunately you are not able to identify where the assigned variables come from. Due to the event driven architecture of Shopware the variables can be assigned to the view after the request has been dispatched to the related Controller. This means that variables might he assigned through third party plugins as well as specific event listeners and store front decorators (in Shopware 5).
Kind regards!
If you want to use your variables inside the template you have to write a plugin and assign your controller-variables to the view.
Check out Globale Variablen im Template verwenden in the shopware documentation.
If you want to use see which variables are allready assigned, you can use {debug} in the template. Also {$sArticle|var_dump} is really helpful, if you want to debug a specific variable ($sArticle} in this example).
You have to known that shopware assigns the members of an object to the view.
Related
I am trying to build a logic app that receives incoming X12 EDI messages. I have an integration account set up and an agreement created. However, I don't see a way to associate a map with an agreement. It seems I have to hard code this in the logic app which would mean one logic app for each trading partner document type. Surely there is a way to select maps based on sender, receiver and document type. This is basic functionality for other EDI packages but I don't have a clue with logic apps.
Not sure whether there is a better way, but you can specify the map name at run time.
Then, as you are already using an integration account, you can externalise Business Rule using liquid templates, as explained here: https://blog.mexia.com.au/business-rules-on-azure-logic-apps-with-liquid-templates
You could pass some metadata about the trading partner to the liquid template, and then return the name of the map and use it in the mapping action.
HTH
Actually, this is almost as easy as BizTalk Server* ;)
Since the Map Name can be composed at runtime, you can upload your Maps using a set pattern, for example [SenderID] + "_" + [MessageType] -> "CONTOSOSID_810"
Then Initialize a Variable set to [SenderID] + "_" + [MessageType] and use that as the Map parameter to the Liquid Action.
Important Point: Every output of the X12 Decoder can loop so you may have to manually index the paths in the Initialize Variable depending on if/how you're debatching the transactions.
*BizTalk Server automatically resolved the Map based on the Party's message Type which you could use here, just that the names are a bit messy.
I'm using Liferay 6.2.
My need is to add one user in LR, with a specific userID.
Or alternately, update a userID with another value.
The standard addUser service does not provide the possibility to specify the userID, and even the updateUser.
I would like to understand how LR choose the IDs for a new user, and if I can modify it.
thanks!
Like in almost any database driven application they're assigned in sequence. And no, you don't have to choose anything, it'll be taken care of by the framework. It needs to be unique, you can't add another user with the same ID and you must be sure that the user with this id will never be created in future. Thus: If you'd use an id that has already been given out, you'd have a duplicate. If you'd use one that has not yet been given out, you'll have a duplicate some time in future, when the sequence of ids comes to this value and the framework assigns the same id for the second time.
If you have an architecture that relies on a specific ID, your architecture is wrong. Rethink the problem and change the architecture and whatever you've already done to implement it.
LR core services use a CounterService to automatically assign UserId (and plugin developer should do the same)... so all the generating code is properly wrapper in the service methods that creates a number of rows in different tables when creating a user.
I agree with previous comment "If you have an architecture that relies on a specific ID, your architecture is wrong"... by the way you can use a tip.
Do you know Expando in LR? In enables you to add virtual columns on a DB entity... by using it, you can create a virtual column "myExternalId" to table "User_" (entity "User") and store there the ID you need. Then modify your code to use the field myExternalId instead userId.
I'm realizing a theme with liferay using velocity. I would like to add some functions to the theme homepage only in the case the user logs in the portal for the first time.
How can I use velocity (portal_normal.vm) to achieve that?
As stated by #Olaf Kock it is not suggested to use the business logic in the theme section.
But, If you want to do it anyway then Liferay provides a set of Velocity Variables that can be accessed in the Themes. Which includes the User details too.
These are some of the User related Variables available globally in themes,
$user_id,$is_default_user,$user_first_name,$user_middle_name .... $user_login_ip, $user_last_login_ip
You can check out more at : themes\_unstyled\templates\init.vm inside ROOT.WAR.
So, For your specific purpose here you can use $user_last_login_ip. If the value is null then it would be the first time the user has logged into the portal.So, use this inside the portal_normal.vm,
#if (!$user_last_login_ip)
... do stuff here if the variable is null
#end
And, Alternately you can fetch the User last login date using and check null to ensure whether it is his first login,
#if (!$user.getLastLoginDate())
... do stuff here if the variable is null
#end
Don't add this to the theme. Rather have a separate custom LoginAction for this. This will be executed on every login (you can choose pre- or post-login, I'm assuming that post-login will be appropriate) and should find some more information than I linked on this topic all over the net.
A theme is made for look&feel and should not contain any business logic - especially not when it's for a one-off purpose.
I have built a website (with MODX) where some products are managed and displayed via the articles addon. The products should have a custom ordering but I don't know how to use a template variable for that.
If I enter the name of the TV in the "Sort Field" field nothing is shown at all.
So is it somehow possible to use a TV there?
Or is there another way to achive a custom ordering (note that I need the summary and date fields, so I cant't abuse them for that)?
You can do this by using getResource package. Look at sorbyTV, sortdirTV, sortbyTVType parameters in manual:
http://rtfm.modx.com/extras/revo/getresources#getResources-SelectionProperties
How to implement Attribute to find his own name in the admin area in Opencart : Products - Attributes - Attributes? Is that there is a separate field and simply by driving into the field and displays the name of the attribute is an attribute, as usual searching for items in the admin by name, but only with attribute
It's hard to understand what you are asking, but if you are trying to use attributes for products then you must first define them at catalog>attributes>attributes.
To List attributes in the Products tab you will need edit these files
admin>view>template>catalog>product_form.tpl
admin>controller>catalog>product.php
If your understanding of PHP or Opencart isn't very strong it will help you to copy data from the attribute.php controller to the product.php controller.
As for the search function, this is something I haven't done before but you could try using the search function on the front of the website as reference.
I recommend working through this as best you can then asking more questions if or when you get stuck.
*Update
Ok so since HTML is your strenth it will be smartest to start from there. Open any of these files (the ones that have the data you need).
admin>view>template>catalog>attribute_form.tpl
admin>view>template>catalog>attribute_group_form.tpl
admin>view>template>catalog>attribute_group_list.tpl
admin>view>template>catalog>attribute_list.tpl
Then work backwards with what you see. The tpl will show variables that look like $attribute, track these back to
admin>controller>catalog>attribute.php
admin>controller>catalog>attribute_group.php
And you will see how all the code is used to pull the data from the model and format it if necessary.