Skip to content

Instantly share code, notes, and snippets.

@xcommerce-gists
xcommerce-gists / layout.xml
Created August 7, 2013 17:49
Sample layout using service calls
<block type="Mage_Core_Block_Template" name="product.info" template="Mage_Catalog::product/view.twig">
<data service_call="currentProduct" alias="productData" /><!-- makes the currentProduct service available in a template using the $productData variable -->
<data service_call="productLinks" alias="links" /><!-- makes the productLinks service available in a template using the $links variable -->
...
</block>
@xcommerce-gists
xcommerce-gists / service_calls.xml
Last active December 20, 2015 16:49
service_calls.xml - Example 2 showing data and request in the same arg
<service_calls>
<service_call name="searchOptimizedProduct" class="Mage_Seo_Model_Product" method="findByAlias">
<arg name="alias">product_id_{{request.params.id}}_sku_{{data.selectedProduct.sku}}</arg><!-- gets a product alias similar to product_id_0_sku_iphone5345673563 -->
</service_call>
<service_calls>
@xcommerce-gists
xcommerce-gists / service_calls.xml
Last active December 20, 2015 16:49
service_calls.xml - Example 1 using path for both data and request
<service_calls>
<service_call name="selectedProduct" class="Mage_Catalog_Model_Product" method="load">
<arg name="id">{{request.params.id}}</arg><!-- ID element from HTTP paraeters substituted during evaluation of the path -->
</service_call>
<service_call name="locateProduct" class="Mage_Warehouse_Model_Locator" method="find">
<arg name="productSku">{{data.selectedProduct.sku}}</arg><!-- substitutes the SKU of the selected product -->
<arg name="zipCode">{{request.params.zip}}</arg><!-- substitutes the zip code from HTTP parameters -->
</service_call>
<service_calls>
@xcommerce-gists
xcommerce-gists / service_calls.xml
Created August 5, 2013 22:01
Simple service_calls.xml
<service_calls>
<service_call name="selectedProductDetails" service="Mage_Catalog_Service_Product" method="item">
<arg name="productId">{{request.params.id}}</arg>
</service_call>
</service_calls>
@xcommerce-gists
xcommerce-gists / layout.xml
Created June 8, 2013 16:40
portion of layout.xml for Magento 2 service calls
<block type="Mage_Catalog_Block_Product_Twig" module="Mage_Catalog" name="product.info"
template="Mage_Catalog::product/view.twig">
<data service-call="selectedProductDetails" alias="product" />
...
...
</block>
@xcommerce-gists
xcommerce-gists / service_calls.xml
Last active December 18, 2015 05:49
service_calls.xml for Magento 2
<service_calls>
<service_call name="selectedProductDetails" service="Mage_Catalog_Service_Product" method="item">
<arg name="productId">{{request.params.id}}</arg>
</service_call>
<service_call name="selectedProductOptions" service="Mage_Catalog_Service_Product" method="getOptions">
<arg name="productId">{{request.params.id}}</arg>
</service_call>
@xcommerce-gists
xcommerce-gists / config.xml
Last active December 17, 2015 21:09
Magento advanced config.xml example: extensibility alpha-1
<?xml version="1.0"?>
<global>
<events>
<customer_delete_commit_after>
<observers>
<customer_deleted_event>
<class>Mage_Customer_Model_Customer_Webhook_Observer</class>
<method>dispatchCustomerDeletedEvent</method>
</customer_deleted_event>
</observers>
@xcommerce-gists
xcommerce-gists / config.xml
Last active December 17, 2015 15:28
Magento simple app/config.xml for webhooks
<?xml version="1.0"?>
<config>
<global>
<webhook>
<subscriptions>
<mysubscriber_alias>
<name>My Sample Order Created Subscriber</name>
<endpoint_url>http://requestb.in/101o8wy1</endpoint_url>
<topics>
<customer>
@xcommerce-gists
xcommerce-gists / system.xml
Created May 22, 2013 22:55
Magento sample shipping carrier configuration for an extension's etc/adminhtml/system.xml: extensibility alpha-1
<config>
<system>
<section id="carriers">
<group id="acme" translate="label" module="Acme_Carrier" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Acme</label>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled for Checkout</label>
<source_model>Mage_Backend_Model_Config_Source_Yesno</source_model>
</field>
<field id="free_shipping_enable" translate="label" type="select" sortOrder="210" showInDefault="1" showInWebsite="1" showInStore="0">
@xcommerce-gists
xcommerce-gists / config.xml
Last active December 17, 2015 15:18
Magento app/config.xml showing custom data format factory for extensibility alpha-1
<global>
<webhook>
<formats>
<json>
<label>My-JSON</label>
<options>
<default_formatter>Mage_Webhook_Model_Formatter_Json</default_formatter>
</options>
<formatter_factory>MyCustomClass_Webhook_Model_Formatter_Factory_Json</formatter_factory>
</json>