I added a new type of image format 3d in my commercewebservices-spring.xml.
I want to access this new format in my product-images.component in Product Detail page, something like:
<ng-container *ngIf="mainImage$ | async as main">
<div *ngIf="main.3d as 3d">
But I get an 'unresolved variable', so I guess I need to add this new format elsewhere in spartacus or there is something I'm missing.
Could anyone help with this? Thanks a lot in advance.
there are a couple of steps you'd need to do:
Make sure that the image has been exposed in the OCC api. The OCC endpoints has a configurable fields mapping, that you can use to control the response. You need to verify if your 3d property is exposed. I'm also not sure if you add this as a new property to the backend product model and if it's a media container or a media. But I assume you figure that out.
Make the Spartacus adapter aware of the new field mapping, this is documented in https://sap.github.io/spartacus-docs/connecting-to-other-systems/#configuring-endpoints. You basically configure the required field, so that the data is requested and automatically stored inside the product state in Spartacus.
Implement the UI. I'm not sure if you like to add the 3d image as part of other thumbs/images, or that you need a dedicated UI for 3d images. If it's completely replacement of the product images, the easiest thing is to replace the current cms ProductImagesComponent mapping, i.e.:
providers: [
provideDefaultConfig(<CmsConfig>{
cmsComponents: {
ProductImagesComponent: {
component: Custom3dImagesComponent
}
}
})
]
This is documented at https://sap.github.io/spartacus-docs/customizing-cms-components/
There are alternatives for each step, but these are most straightforward.
If you look at ProductImageNormalizer (https://sap.github.io/spartacus/injectables/ProductImageNormalizer.html#source) you can see that the mapping is slightly different: either image.primary.<format> or image.gallery[n].<format>
Also, bear in mind that the format codes used in the DTO are mapped in the SAP Commerce side. There is an ImageFormatMapping concept, which maps from the actual media format used in the data model in SAP Commerce to the format strings used in the DTO.
Related
What is the approach if want to add a new attribute to the Product(Model/Data/DTO) in SAP Commerce Cloud and
wanna to access it in Spartacus (using Spartacus ProductService)?
How to introduce the attribute to the Product model in Spartacus and get it populated with the value from the backend?
This question can be seen as a general question how to apply this requirement to all models and keeping the models in sync between backend and frontend.
Thank you in advance.
In order to fetch additional attributes, you can configure the endpoint. See https://sap.github.io/cloud-commerce-spartacus-storefront-docs/connecting-to-other-systems/#configuring-endpoints for more information. There's no need to convert (normalize) the data necessarily, but you could do this as well. This is covered in the same documentation. And you could even replace the standard OCC adapters by a custom adapter if you need to adapt a 3rd party backend.
Once the data is loaded from the backend, it will be stored in the central store, and exposed by the facade without limitation. You might however want to enhance the default typing, in order to benefit from type-safety and not fallback to any. You can do this with the following:
// intro custom typing
interface CustomProduct extends Product {
customAttribute?: string;
}
// use typing for the observed data
product$: Observable<CustomProduct> = this.currentProductService.getProduct()
I am developing a module for electronic invoicing, and should express the payment term in spanish, so I am setting a dictionary with all the needed fields, and when I do this:
{
...
'FmaPago': inv.payment_term.name,
...
}
The output file contains the value "name" in english. I've tried something like
_(inv.payment_term.name)
but with the same result.
How should I force the value to be expressed in a defined translation?
The field name of Payment Terms are already translatable. You can change the translation in Odoo by clicking the little button within a field in edit mode.
If you've done that correct, you have to avoid some typical mistakes at code side if you use the old API.
always pass the context
e.g. if you browse the invoice, pass the context, to get all translations correct
use partner language if you want to translate for them
Odoo is using user language in his context, to translate the web client correctly. If you print documents for customers, you want them in customer language of course...
So you maybe need to manipulate the context (key 'lang'). For new API you have to call with_context() to do that.
You must use _() for strings that you want to be able to translate.
You must make translating files *.po (as i remmember) and thats all I think.
Dont forget to check documentation link
I am creating a hypermedia api that conforms to the HAL spec
When a user submits a payment they need to specify what type of card they are using (Visa, Master Card etc)
So for a particular field that is submitted there is a specific list of values that can be used
How do I present that pick list to the user?
As embedded data?
Is there generally a way to associate a field with a given set of data?
I realise the HAL spec is very small and doesnt cover this issue specifically. But in general hypermedia apis how do people usually present this data?
Or should I simply explain the field in the CURIE link?
thanks
You are right, HAL does not specifically cover this issue. You can solve this by essentially copying HTML. There are different widgets defined in HTML to present stuff, for example a combobox with listed options.
You can define a media-type that has similar controls in it, and you can define the processing model for the media-type as well. It can be a json representation of course, does not need to be xml.
For example
{
...
"cardType": {
"inputType": "select",
"possibleValues": ["Visa", "MasterCard", ... ]
}
...
}
There is no ready-made format that I know of unfortunately.
Our company would like to use the Sketchfab API to show building constructions to clients. This works perfect, but we would like to use the feature to create annotations on the 3D models within Sketchfab.
I couldn't find anything about creating/editing annotations with the API they provide. This is possible on the site itself.
Does someone know how to create those annotations with Sketchfab from another site (embedded or with API), or knows about a 3D web modeling program/framework which can do that?
Thanks in advance!
This is now possible with new annotation functions:
https://sketchfab.com/developers/viewer/functions#api-section-annotations
Annotations are notes positionned in 3D space. They allow authors to provide information on a specific part of the model and tell a story.
Specifically https://sketchfab.com/developers/viewer/functions#api-createAnnotation
createAnnotation( positionStart, positionEnd, eye, target, title, text, callback, [callback] )
Create the annotation with the given parameters. Callback will be passed (err,index).
And also https://sketchfab.com/developers/viewer/functions#api-updateAnnotation
updateAnnotation( index, {title: title, content: content, eye: eye, target: target}, [callback] )
Updates the annotation information for the given index. Callback will be passed (err, information).
It's not possible yet. But the viewer api should be updated 'soon' to support more feature.
So what are the cool kids using for displaying documents inside a SharePoint Hosted App Model? Right now, I'm doing rest calls and attempting to display the data using jquery datatables plugin. It works but isn't exactly usable, not to mention that I have to make additional async calls to get Author names, etc.
Should I dump REST and use CSOM and format the data accordingly? Build the hyperlink to the item, format date, build Author name.
Seems like I'm re-inventing the wheel here and want to make sure that I'm not overlooking something obvious.
Thanks
Out of interest, what about DataTables is not usable? If the data is in the JSON return, it can obtain the data directly. Sorry, I know this doesn't help you, but I'm trying to make DataTables better, so I'm interested to know what use cases it is failing to deliver on at the moment!