How to display a custom attribute on Cart Page in hybris? - tags

I have a custom attribute whose value I have to display for every item in the cart on the Cart Page. I want to add the attribute in cartItem.tag. Can someone please tell me where should I add the value? I tried adding it in the CartPageController, but could not find an appropriate place to add the value.
I'm completely new to Hybris, any help would be appreciated.
Thanks, in advance.

I am guessing this new attribute belongs to the OrderEntryData type. You can use or create some Populator to add value to this attribute. You should use populators when you want to copy some value from modelObject to dataObject in order to show it whithin the presentantion layer.

Steps you need to follow:
Add new attribute on CartEntryModel at item level where, your new attribute value will get store on model
Add new attribute in CartData using **beans.xml, which will hold and show value on cart page
Create new custom populator by extending commercefacades's "CartPopulator" and populate new attribute value
Finally, you can use new attribute directly on cartPage via. cartEntry.newAttribute

Related

Difference between UserProperties.Add and UserProperties.Set functionality in FlurrySDK

I'm using Flurry Analytics in my Unity game and I want to use Flurry UserProperties.
My question is about the difference between the functionality of UserProperties.Add and UserProperties.Set methods in FlurrySDK.
In the documents there is following description :
Set :
Sets and replaces (if any exist) the value(s) for the property.
Add :
Adds a User Property value(s). Adding values already included in the state has no effect and does not error.
Can I just use Flurry.UserProperties.Add whenever I need to set/add an UserProperty for a user and ignore Flurry.UserProperties.Set?
or I need to first define every property with Flurry.UserProperties.Add to be added in Flurry's panel and then use Flurry.UserProperties.Set to set them for a specific user?
Add adds to existing values, while Set removes existing values and then adds the new one
To create your custom User.property you do it in the Admin Panel of Flurry.
Set, clean your property and set with your last value you send.
Add , preserve the old values and add a new value to your property.

Smart Table, onclick event

Is it possible to handle an onClick event on a Smart Table? I have annotated data coming from my backend. When clicking on an entry, I want to navigate to a new view displaying all data associated with the entry I clicked on.
How can I achieve this in SAPUI5? I can get the internal table with getTable in my JavaScript Controller, but how do I proceed?
On sap.m.Table you can add attachItemPress(oData?, fnFunction, oListener?) and fnFunction will be called to handle the item press.
Because you are trying to use a SmartTable, you need to take into account the TableType. This will really determine the means to handle the 'click'.
Check the tableType of your smartTable and then follow the api reference for that table. If the tableType is sap.ui.comp.smarttable.TableType.ResponsiveTable, then the above should work.
For me works attachSelectionChanged(oData?, fnFunction, oListener?) : sap.ui.model.SelectionModel.
And after this I used that help https://stackoverflow.com/a/36913953/6039287 for get row item params.
Works perfect:)

AEM DefaultValue written to JCR

I noticed that when I set my defaultValue for a dropdown, altho it is correctly selected in the drop down when I first add my component to the page it does not write the defaultValue to the corresponding JCR until I edit the component and save it. Even if I just open the corresponding dialog and click OK now my component works as expected because the values have been added to the JCR.
I am sure there is an important piece that I am missing here, does anyone knows how defaultValues that are required in order for the component to render properly can be added to the JCR when they are first added to the page?
Like Shwan say's that's the way it works. The default values or empty texts are only for the dialog. They aren't persisted until the dialog is authored. The properties have to be set by a different method. CQ already ships with this feature and you can do it without any custom code.
Under your component , create a node called cq:template[nt:unstructured] . If all the data is stored on the component node itself , add the default values as properties to cq:template node with name same as the ones in your dialog. In case the data is stored in a child node add a similar node under cq:template node.
Source : http://blogs.adobe.com/experiencedelivers/experience-management/defaults-in-your-component/
I believe that is simply the way it works. The default value specified in a dialog does not get used until the dialog is loaded/saved, so until that happens the node on the JCR repository that is being authored won't have the default value.
We got around this on a project by adding back-end code that was tied to the component (a tag) so that when the component was loaded, if the property did not exist, it would be written with the default the first time. Ex:
if (wcmMode == WCMMode.EDIT )
{
if(!currentNode.hasProperty("SomePropertyThatWillAlwaysExistIfTheDialogHasBeenSaved")) {
currentNode.setProperty("PropertyThatShouldHaveDefault", GlobalConstants.TRUE);
currentNode.getSession().save();
}
}
Like Sharath Madappa say's that's the way it works fine if component name and jsp name same. If you dont have componentname.jsp under component or page, cq:template won't work.(Reference:http://labs.6dglobal.com/blog/2014-07-08/using-the-cq-template/)
If you hava componentname.html under your component, changed the node [cq:template] type to [cq:Template] instead of [nt:unstructured]. In this case, defaultValues can be added to the JCR when they are first added to the page.

Magento: How to add attribute to product price?

I created a new attribute (delivery) for my Magento shop and I'd like to show this attribute right after the product price on the product page. How can I do that?
I tried to add echo $_product->getdelivery() at view.phtml but my attribute showed up in the next line and not next to the price.
Try adding your code to catalog/product/price.phtml
else you can add css to .price-box but this would change in many places as price-box is used in many places
Better to add a class in price.phtml to price-box. Give the new class float left and add your div next to it. :)

enterprise architect api: Add element to a collection

I have few short questions regarding Enterprise architect.
My question is regarding the automation interface. When following the instructions provided on this page: http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/colle... in order to add a new element to the collection ( and the .eap file) it does not add the element. I can get data from the elements, modify and even delete them, but adding a new element does not work?
Instructions provided:
Call AddNew to add a new item.
Modify the item as required.
Call Update on the item to save it to the database.
Call Refresh on the collection to include it in the current set.
my java example:
elements is a collection of all the elements in the model...
org.sparx.Element elementEa = elements.AddNew("Requirement", "non-functional");
elementEa.Update();
elements.Refresh();
With the api is it possible to change the id or guid of an element since there are no methods specified in org.sparx for that?
One last thing... Is it possible to create a custom element in EA, for example a requirement which will not have the standard properties like difficulty, priority etc.. , but will have others? (normal properties, not tagged values)
The arguments to AddNew() are Name and Type, so to create a Requirement element you should specify "SomeRequirementName" and "Requirement".
You can't change the ID or GUID through the API, and your models would crash and burn if you did (connectors would be left dangling, elements would vanish from diagrams, etc, etc).
With an MDG Technology you can create very detailed stereotyped elements if you like, with their own visual representations (shape scripts) etc, but if you're after creating an element type with its own properties dialog the answer is no; there is no hook for a custom dialog in the API.
Collection<Package> packageCollection = myPackage.GetPackages();
Package consolidatedCfsSpecPackage = packageCollection.AddNew("somePackageName", "");
if (!consolidatedCfsSpecPackage.Update()) {
System.err.println("Not Updated: somePackageName");
}
packageCollection.Refresh();
This works for me. I suggest you to check return value of elementEa.Update() method you called. If it returns false, you can get the reason by calling elementEa.GetLastError().