Magento 2 - How show product price in dropdown choose an option - attributes

I want to show the product difference price in the dropdown list for configurable product (choose an option) same as in magento 1.X Thanks to all!

This is a known issue in Magento 2
The JavaScript array which is used for the picklist is generated in the method getJsonConfig() in the Class
app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
There you see two arrays added to $config: attributes and optionPrices.
attributes seems to contain the labels that are used for the dropdown.
optionPrices contains the prices which are used to refresh the price after a customer selects a different option (with a different price associated).
This will make it very difficult to show the price difference in the dropdown as the price difference values would need to be calculated in the JavaScript.
One solution that is relatively easy to implement would be something like this, but this will show the final price of each option, not the price difference:
Create a Magento 2 plugin module that is triggered after the getJsonConfig is executed: afterGetJsonConfig()
Then use the output of the getJsonConfig in afterGetJsonConfig(): $config, this array contains attributes and priceOptions array, amongst others.
First jsondecode $config
Then walk through the attributes array to determine the available options
For each option, find the matching price in priceOptions array.
Update each option label in the attributes array by concatenating the price (correctly formatted) to the existing label.
jsonencode $config
return $config

Related

Multi select employees in Employee Time Activities

I was trying to enable multi-select for Owner in Employee Time Activities and wanted to try based on below article.
https://asiablog.acumatica.com/2018/01/multi-select-selector.html
Then override view like below:
https://asiablog.acumatica.com/2017/11/sql-in-operator-in-bql.html
However, after I added ValidateValue = false in field:
I am getting this error.
I looked at the custom attribute and I don't think it could be replaced with anything keeping the same implementation.
So, is there any other way I can accomplish multi select feature to allow display Employee Time Activities for selected employees at once besides the ideas mentioned above?
Thanks.
Your primary issue is that DimensionSelector is different than Selector.
Secondary thing to keep in mind that when you do Multiselector you would need to update the field that holds the values to have a longer length. The way a multiselector works is that it stored the saved values as a ; (semicolon) separated string. so if the field was 10 long you would want to expand to whatever you expect the max number of selected values would be, e.g. 40 would be 480, 40x10 + 40x2, 10 being the original size, 2 being a semicolon and space. (hope that makes sense :) )
Next you would have to update all the functional business logic to then parse that string and loop each, in this case, employee for the functions.
I am speaking very generically here. So not sure what you're actually attempting to do here, but one would assume that if you were selecting multiple employees you would want records to reflect accordingly.

Create relationship between two lookup columns in a sharepoint list

I have a Sharepoint List 'TeamValues' that defines values that should appear in another list.
TeamValues List:
Title Team Sub-Team
1 A Blue
2 A Green
3 B Yellow
4 C Silver
5 C Gold
I have a list that users can edit and in this list I want to lookup 'TeamValues' list and create a dropdown list for users to select a value from the Team column. This needs to be unique so in this case the values that should appear are: A,B,C
Once they select a value I need a second column to populate a drop down list that users can select E.g. If they select Team: A, then the second drop down should show: Blue, Green as the options.
How can I do this using Sharepoint? I don't have any code access and only have the sharepoint GUI to work with.
Is this possible?
I have created a lookup choice column Team that looks at my TeamValues List however this is showing all values e.g. A,A,B,C,C. I have created a lookup choice column for the subteam that also shows every value. I dont know how to link these together or get a relationship between the two choice drop downs/ remove duplicate values. I tried the following option: 'the Enforce unique values is not displayed.' which did not work
No code applicable
I am sorry to say that but I think there is no OOB functionality to show distinct values of lookup column and to do this kind of relation without any code. I also did some research just to be sure but I could not find anything like that.
If You would consider some code You can always use javascript jsLink technology to achieve this. It's not that hard. It's a JS file that You can add to some lib on sharepoint site and then You can add this JS to webpart manually without any deploy or other. After that with javascript You can overwrite the default behavior of any control/column and do this kind of relation or show only distinct values.

Spotfire: How to use trellis to show 4 elements: 3 years + set of records older than 3 years?

Lets say I have the data about some kind of requests.
I have column determining request's creation date.
I wish to show the requestes Trellis'ed by this date but not the standard way.
I wish all the requests with creation date older than 2013-01-01 to be grouppped in one trellis graph.
I also would like to retain the possibility to have information on both year and quarter level as it is available for typical date column.
The image below show sth similar to what I need but the Empty section comes as the last one and I need it with different label and on the left hand side rather than as it is now on the right hand side.
Any ideas ?
my suggestion is to make two visualizations. you can duplicate the one you've already created and then limit its data by editing the properties for that vis, viewing the Data page, and using the Limit data using expression field, giving an expression like [Date Column] < "2013-01-01". you'd do the same on the second vis except use an expression like [Date Column] >= "2013-01-01".
the easiest way to change (Empty) to "something" is to not leave it empty :) you can create a calculated column with the expression If([Column] is null, "Custom Empty", [Column]) and then use that on the horizontal axis. alternatively you can hide (Empty) values from a visualization by limiting the visualization by an expression like [Column] is not null.
you can adjust the order which values are shown by going to the Edit menu and choosing Column Properties. choose the column, click the Sort Order tab, select Custom Sort Order, and click Configure.

how to display sum of field in axgridview

I'm working with Microsoft Dynamics AX R3,2012 and i want to add a group by field in an dynamics:AxGridView then a sum for a certain field by the group field indicated then the total sum without the group by .Please help me .i didn't find a solution.like what described in this page http://www.agrinei.com/gridviewhelper/gridviewhelper_en.htm
You can create a display method to compute your sum on each row. If you do so, don't forget the 'cacheAddMethod' in order not to compute it each time. This is the "historical" way.
More info on display methods.
Or you can create a view and use computed column in it. It will depends on your current datamodel and query you want to run.
More info on computed column in views.
Thanks for your reply,My Problem is not to create display method but the Problem is how to display the sum of subtotal by this display field.So my solution is to add GroupField in the AxGridView with designed field like GoalId in my case.then in the AxGridView i create template field with footer containing label not visible in default. So in rowdatabound i do the total by the new group that known with a test in rowcreated in GoalId 's value changes .Then when i get a new group i put the value of cumul of the previous value of a the previous group and in the footer template i display the total of all rows.this is the solution and thanks so much for your help. but now the problem that i noticed that axgridview have problems after updating data with a groupby fields and with template field.it display noting in this fields

SPD: calculated column with data from another list

I'm in the same situation described HERE.
I'm trying to use Create List Item and Update List Item actions (like suggested in the answer) but without any results.
Could someone kindly explain the procedure mentioned in the answer?
Thank you,
Marcello
I posted an answer there, but here is a copy in case it gets deleted or removed:
lem.mallari's answer is a huge pain unless you can assume that the Amounts in List A never change, since it's not tracking whether an item has already been added to the sum. There is no way for a Workflow to iterate through a SharePoint list, which means there is no easy way to calculate the sum or average of multiple list items.
The correct way to implement this will will require some development. The SharePoint Developer Training (2010, 2013) will actually get you most of the way there: an event receiver should trigger when items are added or changed in Lists A and B that uses SharePoint's API to go through List A and average values by Name, then update all (or just affected) items in List B. Alternatively, you can use JavaScript to display the sum of all entries in List A that have the same name as the item in List B as long as all the data is displayed on your page. If you're handy with XPath and InfoPath, you could add List A as a secondary data source to List B's form and select only applicable items in List A to sum from.
But if we're talking Workflows, here's the "workflow only" method. This was tested and successful in 2010. Create custom List C with the following columns:
Title (string, mandatory, enforce unique values)
TotalItems (integer, mandatory, default 0)
Sum (number, decimal places however you want, mandatory, default 0)
Average (calculated, =IF(TotalItems=0,0,Sum/TotalItems)) (optional)
Replace the Name columns in Lists A and B with lookup columns pointing at List C. Delete the Amount column in List B, instead including the Sum column as an additional column. Add the following columns to List A, and ensure that users cannot change them directly. This can be restricted by making InfoPath forms or by making alternative view and edit forms.
AmountArchive (number, identical to Amount, default 0)
AmountHasBeenSubmitted (yes/no, default no)
Create a Workflow to run each time an item is created or modified in List A. Use these commands (I'm using a list for readability; it was getting ugly when formatted as code):
If Current Item:Amount not equals Current Item:AmountArchive
Set Variable:Item Count to (Data source: List C; Field from source: TotalItems; Find the List Item: Field Title; Value: Current Item:Name(Return field as: Lookup Value (as Text)))
Calculate Variable:ItemCount plus 1 (Output to Variable: ItemCount)
Calculate List C:Sum (similar settings as above; be sure to use Lookup Value (as Text) and not String!) minus Current Item:AmountArchive (Output to Variable: SumWithoutValue)
Calculate Variable: SumWithoutValue plus Current Item:Amount (Output to Variable: NewSum)
If Current Item:AmountHasBeenSubmitted equals No
Set AmountHasBeenSubmitted to Yes
Update item in List C (Set TotalItems to Variable:ItemCount; Set Sum to Variable:NewSum; Find the List Item in the same way of Field:Title; Value: Current Item:Name(Return field as: Lookup Value (as Text))
Else
Update item in List C (don't do anything to TotalItems; use the same logic to set Sum to Variable:NewSum)
Set Amount to Current Item:AmountArchive

Resources