Posts Tagged magento

Send email to CustomerService team from magento

$templateId = 1; # Transactional emails template
$mailSubject = 'your topic';
$sender = Array('name'  => Mage::getStoreConfig('trans_email/ident_support/name'),
'email' => Mage::getStoreConfig('trans_email/ident_support/email'));

$vars = Array('item'=>'item123', # your vars
'order'=>'order123');
$storeId = Mage::app()->getStore()->getId();
$translate  = Mage::getSingleton('core/translate');
Mage::getModel('core/email_template')
->setTemplateSubject($mailSubject)
->sendTransactional($templateId, $sender, $sender['email'], $sender['name'], $vars, $storeId);
$translate->setTranslateInline(true);

Tags: , ,

Magento invoices mysql table located

If you’re looking where Magento stores its invoices, first step was to locate table sales_order_invoice, but such table doesn’t exists.

Good starting point is always a Magento API, which shows you a little bit how to digg for information.

I’ve located api.xml file responsible for invoices API and then found Model which does all magic.

app/code/core/Mage/Sales/Model/Order/Invoice/Api.php

Check method

public function items($filters = null) – to get all invoices

or

public function info($invoiceIncrementId)  – how to read invoice details

Next very important thing – Entities – this will tell you how all elements are structured and where located in mysql table

app/code/core/Mage/Sales/Model/Entity/Setup.php

For example:

'invoice' => array(
'entity_model'      => 'sales/order_invoice',
'table'             =>'sales/order_entity',

Invoices are store in sales_order_entity ( try SELECT * FROM sales_order_entity WHERE entity_type_id = 16)

Invoices items

'invoice_item' => array(
'entity_model'      => 'sales/order_invoice_item',
//'table'=>'sales/invoice',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id'     => array(
'type'=>'static',
'backend'=>'sales_entity/order_invoice_attribute_backend_child'
),

That should be enough to see what’s going on

Tags: , , ,

Converting price from one to another in magento

I found snippet here, but it seems it is broken as second parameter (target currency) is expected to be object

So correct would be


$targetCurrency = Mage::getModel('directory/currency')->load('EUR');
$price = round(Mage::helper('directory')->currencyConvert($priceToConvert, 'GBP', $targetCurrency), 2);

Tags: , ,

Fontis Recaptcha Magento Extension error solved

If you have problem with Fontis Recaptcha Magento Extension like below, read.

Invalid method Fontis_Recaptcha_Block_Review_Form::escapeHtml(Array
(
 [0] => Rating
)
)

Problem is that some of the methods in template are using non existing method. This only happend on product review form page.

edit app/design/frontend/default/default/template/fontis/recaptcha/form.phtml

Replace:

$this->escapeHtml(

with

$this->htmlEscape(

That’s it

Tags: , ,