How can I change the price format used in email templates? - orocommerce

I need to send an email notification when a new Order is received and I need the price to be formatted in a different way than the rest of the site.
Is there a way to send parameters to oro_format_price?
I tried to replace oro_format_price with a simple number_format but it didn't work...
Thanks
Edit:
Digging around the code (Here and here) I found there are options to be passed to oro_format_price filter so I put this code in my email template:
{{ item.price.value|oro_format_price({symbols: {decimal_separator_symbol: '.', grouping_separator: '' }}) }}
Which is not showing me any error, but I'm not getting any email either :(
I'm using version 3.1.17 BTW
Edit 2:
I've checked again and I found somethings I had written wrong, my current version looks like this:
{{ item.price|oro_format_price({symbols: {decimal_separator_symbol: '.', grouping_separator_symbol: '', monetary_grouping_separator_symbol: '', currency_symbol:'' }}) }}
Now the email is sent but the format is not changed :(
Edit 3:
I changed it again to try and use a simpler way:
{{ item.price.value|number_format(2, '.','') }}
and found these errors in the log:
app.ERROR: An error occurred while processing notification {"exception":"[object] (Oro\\Bundle\\EmailBundle\\Exception\\EmailTemplateCompilationException(code: 0): Could not found one email template with \"order_confirmation_test\" name for \"Oro\\Bundle\\OrderBundle\\Entity\\Order\" entity at /usr/share/nginx/html/oroapp/vendor/oro/platform/src/Oro/Bundle/EmailBundle/Provider/EmailTemplateContentProvider.php:71)"} []
app.ERROR: An error occurred while sending "Oro\Bundle\NotificationBundle\Event\Handler\TemplateEmailNotificationAdapter" notification with email template "order_confirmation_test" for "Oro\Bundle\OrderBundle\Entity\Order" entity {"exception":"[object] (Oro\\Bundle\\NotificationBundle\\Exception\\NotificationSendException(code: 0): Could not send notification of type \"Oro\\Bundle\\NotificationBundle\\Event\\Handler\\TemplateEmailNotificationAdapter\" for email template \"order_confirmation_test\" for \"Oro\\Bundle\\OrderBundle\\Entity\\Order\" entity at /usr/share/nginx/html/oroapp/vendor/oro/platform/src/Oro/Bundle/NotificationBundle/Manager/EmailNotificationManager.php:125)"} []
I tried to output the same through a regular template (outside of an email I mean) and it worked ok.
Looking at php error_log file I found this message:
"NOTICE: PHP message: PHP Notice: Calling "getvalue" method on a "Oro\Bundle\CurrencyBundle\Entity\Price" object is not allowed in ...
I checked the class Oro\Bundle\CurrencyBundle\Entity\Price and the getValue method is public so I don't understand why this is failing :(

Email templates have a separate twig rendering engine with a limited list of available functions. This is achieved using the sandbox extension.
To expose a function to the email rendering engine you can use Oro\Bundle\EmailBundle\DependencyInjection\Compiler\AbstractTwigSandboxConfigurationPass.
For example, see an existing implementation, like \Oro\Bundle\PaymentBundle\DependencyInjection\Compiler\TwigSandboxConfigurationPass

Related

Mule 4: uriParams size is showing as 0 even though it is there

So I created a endpoint inside the raml file such as:
/proxy:
/{proxyDestinationTarget}:
uriParameters:
proxyDestinationTarget:
type: string
example: "myurl.com"
post:
description: Pass through operation that targets IAA
is: [client-credentials-required,standard-error-responses,traceHeaders]
and then inside of the logic.xml in my variable component I have
attributes.uriParams.'proxyDestinationTarget'
when I send the request in postman and debug i am getting a uriParams size of 0
the url i entered in postman is
https://localhost:8092/proxy/uat.something.somethingElse.com/Assign/Assignment.svc
but if i send a request like this :
https://localhost:8092/proxy/uat.something.somethingElse.com
I get a uriParam size = 1 which is what I want. I guess the / is whats causing the problem. how can I pass url as uri param with escape characters???
It looks like you are not sending an URL that matches the RAML definition in the first case.
For the URL:
https://localhost:8092/proxy/uat.something.somethingElse.com/Assign/Assignment.svc
The RAML defined that the API should expect /proxy/{proxyDestinationTarget} but it is receiving something like /proxy/{proxyDestinationTarget}/Assign/Assignment.svc, where {proxyDestinationTarget} is uat.something.somethingElse.com, but nothing matches /Assign/Assignment.svc. The API should include those two last components too to match. It is not escaping them, they probably need to be defined.

odoo res.partner address fields access error on website

I am trying to show address fields on website but it gives access error. For some reason I can't use the contact widget on website.
When I visit the page as public user it shows 500 Internal Server error. But if I am admin, everything works.
In my xml template I wrote following:
<span t-field="event.address_id.city" groups="base.group_public"/>,
<span t-field="event.address_id.country_id.name" groups="base.group_public"/>
In ir.model.access.csv file I wrote following:
access_res_partner,res.partner,base.model_res_partner,base.group_public,1,0,0,0
also tried
access_res_partner,res.partner,base.model_res_partner,,1,0,0,0
But it shows following error:
AccessError: (u'The requested operation cannot be completed due to
security restrictions. Please contact your system
administrator.\n\n(Document type: res.partner, Operation: read)',
None)
Error to render compiling AST AccessError: (u'The requested operation
cannot be completed due to security restrictions. Please contact your
system administrator.\n\n(Document type: res.partner, Operation:
read)', None) Template: website_event.index Path:
/templates/t/t/div/div[2]/div[2]/div[1]/ul/li/div/div/div[3]/div/div[3]/span[1]
Node: ,
I also tried this in xml without groups, but result is same:
<span t-field="event.address_id.city"/>,
<span t-field="event.address_id.country_id.name"/>
How can I resolve this.
Try this code.
<span t-field="event.address_id.sudo().city"/>,
<span t-field="event.address_id.sudo().country_id.name"/>
Please make sure you understand the security section in the odoo documentation. In my opinion, it is no good idea to give the base.group_public group generally read access to your customer data.

Extract report results with CloudConnect

I would like to extract raw report results within the CloudConnect process.
So far I have managed to get response from the raw report API end point - https://secure.gooddata.com/gdc/app/projects/{project_id}/execute/raw/
This response contains URI to the file and if I put that URI to browser, file is uploaded.
I have tried passing this URI to the following readers without success:
CSV Reader produces the following error:
------------------- Error details ------------------
Component [CSV Reader:CSV_READER] finished with status ERROR.
Parsing error: Unexpected end of file in record 1, field 1 ("date"),
metadata "outOfStock";
value: Raw record data is not available, please turn on verbose mode.
File Download - I don't know how to pass the URI through the port to "URL to Downlaod" parameter.
HTTP Connector again I don't see how to pass URI from the port.
What is the way to do this?
EDIT
If I use the HTTP Connector as suggested by #Filip, I get the following error:
Error details:
Component [HTTP connector:HTTP_CONNECTOR] finished with status ERROR. hostname in
certificate didn't match: xxx.com != secure.gooddata.com OR secure.gooddata.com
I have tried setting header to X-GDC-CHECK-DOMAIN: false with no effect.
The HTTP connector is the right component to go with. Leave the URL property empty and use the component’s property called “Input mapping”, where in the graphic editor you can assign the input edge field to the URL field.
Solution from GoodData support:
HTTP connector can be also used, but it is very complex, because
logging in to GoodData has to be created. REST connector has it built
in.
If you want to run the example graph, you have to be logged in in
CloudConnect with a user who has access to the project from where you
would like to export the report. You also have to change URL to
the one of white-labeled account in both REST connector components and change project
and report definition in the first REST connector.
So the graph that works looks like this:
Here are the main fields that you will need to set for each element:
Get Results URI - set params for POST request:
Request URL = https://secure.gooddata.com/gdc/app/projects/${GDC_PROJECT_ID}/execute/raw/
Request Body =
{
"report_req": {
"reportDefinition": "gdc/md/${GDC_PROJECT_ID}/obj/${OBJECT_ID}"
}
}
Get URI from Response - just map uri value to corresponding field:
<Mapping cloverField="uri" xpath="uri"/>
Load Results - make sure it is connected to metadata with two fields, one for response with data, other to pass through the uri.
Load Results - you will need to exclude uri field to process the data:
Exclude Fields = uri

Use URL as an API method for Slackbot in Express js

I am still new to javascript and trying to write a Slackbot in express js. I want to use the method defined in https://api.slack.com/methods/channels.history. How should this look syntacticly and how do I use it since the method is simply a URL?
You need to make an http request for the URL and you'll be returned a response with an object containing the status (ok:true|false), if there are more messages (has_more:true|false), and then an array of the actual messages (messages:array).
The response should look something like this:
{
has_more:true
messages:Array[100]
ok:true
}
The url that you make the get request to should look something like:
https://slack.com/api/channels.history?token=BOT_TOKEN&channel=CHANNEL_ID&pretty=1
Where BOT_TOKEN is the token attached to the bot you created, and CHANNEL_ID is the ID (not the name) of the channel whos history you want to get (9 uppercase alphanumeric characters, starts with a "C").
There are also a few other parameters you can include in the url. For example, "latest=", "oldest=", "inclusive=", "count=", and "unreads=". Details about those parameters can be found on the page you linked to (https://api.slack.com/methods/channels.history).
If you want to test it out in your browser's console, find a page where jQuery is loaded, open your dev tools and head into the console, and enter the following (with your bot token and channel id swapped in):
$.get('https://slack.com/api/channels.history?token=BOT_TOKEN&channel=CHANNEL_ID&pretty=1', function(response){console.log(response)});

Magento API Data Type: CartCustomerEntity

While trying to create a cart via the Magento API, I am having trouble adding an existing user as the owner of the cart. I am working with the documentation they provide here:
http://www.magentocommerce.com/wiki/doc/webservices-api/api/cart#cart_customer.set
I called "customer.info" using my specific customerId, then just passed the results to that cart_customer.set method, praying that was what it was asking for. It returned (from PHP)
Fatal error: Uncaught SoapFault exception: [1045] Customer's mode is unknown in ...
I looked at the example at the bottom of the above referenced page and they only had an example for a new guest user, 'mode' set to 'guest'. I was wondering if anyone knew what the other options were for that 'mode' key? Documentation on that data structure in general would be a great help.
Thanks.
Via my own comment:
Ah ha! Found buried in their forum:
$customer = array( 'entity_id' => 6, 'mode' => 'customer' ); via http://www.magentocommerce.com/boards/viewthread/232778 I guess that is all you need to pass. This isn't really a great explanation but it does solve the original problem.
Just gonna flag this one as done.