Load product by SKU
To get a product by its SKU you can do:
1 2 |
$iProductId = Mage::getResourceModel('catalog/product')->getIdBySku($sSku); $oProduct = Mage::getModel('catalog/product')->load(iProductId); |
To get a product by its SKU you can do:
1 2 |
$iProductId = Mage::getResourceModel('catalog/product')->getIdBySku($sSku); $oProduct = Mage::getModel('catalog/product')->load(iProductId); |
Here is a collection of marker that can be used in email templates, cms pages and static blocks. Get system configuration fields
1 |
{{config path="web/unsecure/base_url"}} |
Customer data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
{{var customer}} -> print all customer data {{var customer.ID}} {{var customer.email}} {{var customer.firstname}} {{var customer.lastname}} {{var customer.name}} {{var customer.password}} {{var customer.created_in}} -> store name where customer was created in {{var customer.dob}} -> customers date of birth {{var customer.password_hash}} {{var customer.prefix}} {{var customer.middlename}} {{var customer.suffix}} {{var customer.group_id}} {{var customer.taxvat}} {{var customer.store.name}} -> storeview name customer is associated to {{var customer.store.group.name}} -> website name customer is associated to |
Conditions
1 2 3 4 5 6 7 8 9 10 11 12 13 |
{{depend order.getIsNotVirtual()}} // only happens if order is not virtual {{/depend}} {{depend salable}} // only happens if data field saleable is set {{/depend}} {{if order.getIsNotVirtual()}} // only happens if order is not virtual {{else}} // only happens if order is virtual {{/if}}(else is optional) |
Blocks
1 2 3 |
{{block type='core/template' area='frontend' template='path/to/template.phtml' variable=$datafield variable2=$datafield2}} {{block id='block_id'}} -> reference to a block in a block / cms page already defined (f.e. in layout file) |
Trigger a layout handle
1 2 3 4 5 6 7 |
{{layout area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order}} {{layout handle="sales_email_order_items" order=$order}} {{layout handle="sales_email_order_creditmemo_items" creditmemo=$creditmemo order=$order}} {{layout handle="sales_email_order_shipment_items" shipment=$shipment order=$order}} |
Order / shipping data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
{{var order.getShippingAddress().format('html')}} {{var order.getShippingAddress().getName()}} -> get first- and lastname {{var order.getShippingAddress().getPrefix() {{var order.getShippingAddress().getFirstName()}} {{var order.getShippingAddress().getMiddleName()}} {{var order.getShippingAddress().getLastName()}} {{var order.getShippingAddress().getSuffix()}} {{var order.getShippingAddress().getStreet1()}} {{var order.getShippingAddress().getStreet2()}} {{var order.getShippingAddress().getCity()}} {{var order.getShippingAddress().getRegion()}} {{var order.getShippingAddress().getPostcode()}} {{var order.getShippingAddress().getCountry()}} -> get the country ID {{var order.getShippingAddress().getCountryModel().getName()}} -> get the countries full name {{var order.getShippingAddress().getRegion()}} {{var order.getShippingAddress().getTelephone()}} {{var order.customer_email}} {{var order.getBillingAddress().format('html')}} {{var order.getCreatedAtFormated('long')}} {{var order.getCustomerName()}} {{var order.getCustomerFirstname()}} {{var order.getCustomerLastname()}} {{var order.getEmailCustomerNote()}} {{var order.getShippingDescription()}} {{var order.getStatusLabel()}} {{var order.getStoreGroupName()}} -> website the order was created on {{var order.id}} {{var order.increment_id}} |
URLs
1 2 3 4 5 6 7 8 9 |
{{skin url="'}} {{store url=""}} {{store direct_url=''}} {{media url=''}} {{skin url=''}} |
Further marker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
{{var addAllLink}} {{var alertGrid}} {{var billingAddress.format('html')}} {{var checkoutType}} {{var comment}} {{var creditmemo.id}} {{var creditmemo.increment_id}} {{var data.comment}} {{var data.email}} {{var data.name}} {{var data.telephone}} {{var dateAndTime}} {{var invoice.id}} {{var invoice.increment_id}} {{var invoice.created_at}} {{var items}} {{var items_html}} {{var message}} {{var name}} {{var password}} {{var payment_html}} {{var paymentMethod}} {{var product_name}} {{var product_url}} {{var reason}} -> f.e: the reason for payment failure in failure mail {{var shipment.increment_id}} {{var shippingMethod}} {{var total}} {{var user.name}} {{var viewOnSiteLink}} {{var warnings}} {{var billing.name}} {{protocol store='' http='' https=''}} {{htmlescape var='' allowed_tags=''}} |
To protect a folder with an password prompt, you only need to place a .htaccess and a .htpasswd into the target directory. .htaccess
1 2 3 4 5 6 7 |
AuthUserFile /root/path/to/.htpasswd AuthGroupFile /dev/null AuthName "Title for the popup window" AuthType Basic <Limit GET> require valid-user </Limit> |
.htpasswd
1 |
username:NiceCryptOrMD5encryptedPasswordHash |
The passwort can be crypted via crypt or MD5. On http://de.selfhtml.org/servercgi/server/htaccess.htm#verzeichnisschutz you can find a useful hash generator. If you have a linux shell you can use:
1 |
$> htpasswd -c .htpasswd username |
Or you can […]
To directly send queries against the database:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//$read = Varien_Db_Adapter_Mysqli extends Zend_Db_Adapter_Mysqli extend Zend_Db_Adapter_Abstract $read = Mage::getSingleton('core/resource')->getConnection('core_read'); $query = " SELECT SUM(`grand_total`) AS `grand_total`, SUM(`subtotal`) AS `subtotal`, SUM(`tax_amount`) AS `tax_amount`, SUM(`discount_amount`) AS `discount_amount`, SUM(`shipping_amount`) AS `shipping_amount`, FROM `sns_salesreport_monthstats` WHERE `year` = $year "; $data = $read->fetchRow($query); //fetches only the first row // or multiple rows: $sql = “ SELECT product_id FROM catalog_category_product WHERE category_id=3 ″; $data = Mage::getSingleton(‘core/resource’) ->getConnection(‘core_read’)->fetchAll($sql); |