Skip to content

Instantly share code, notes, and snippets.

@lemonskip
lemonskip / basic_built_component.js
Created June 12, 2013 08:56
As we move forward modularising our apps and building components into one file. We may find that a lot of these components will share the same modules (e.g. third party libs ... jQuery, Backbone etc ). This introduces a problem ... how can we manage these cross deps without complicating the developers workflow and build process of a component. T…
define(function(){
/** Almond JS:START */
var requirejs,require,define;(function(e){function c(e,t){return f.call(e,t)}function h(e,t){var n,r,i,s,o,a,f,l,c,h,p=t&&t.split("/"),d=u.map,v=d&&d["*"]||{};if(e&&e.charAt(0)==="."){if(t){p=p.slice(0,p.length-1);e=p.concat(e.split("/"));for(l=0;l<e.length;l+=1){h=e[l];if(h==="."){e.splice(l,1);l-=1}else if(h===".."){if(l===1&&(e[2]===".."||e[0]==="..")){break}else if(l>0){e.splice(l-1,2);l-=2}}}e=e.join("/")}else if(e.indexOf("./")===0){e=e.substring(2)}}if((p||v)&&d){n=e.split("/");for(l=n.length;l>0;l-=1){r=n.slice(0,l).join("/");if(p){for(c=p.length;c>0;c-=1){i=d[p.slice(0,c).join("/")];if(i){i=i[r];if(i){s=i;o=l;break}}}}if(s){break}if(!a&&v&&v[r]){a=v[r];f=l}}if(!s&&a){s=a;o=f}if(s){n.splice(0,o,s);e=n.join("/")}}return e}function p(t,r){return function(){return n.apply(e,l.call(arguments,0).concat([t,r]))}}function d(e){return function(t){return h(t,e)}}function v(e){return function(t){s[e]=t}}function m(n){if(c(o,n)){var r=o[n];delete o[n];a[n]=true;t
# Extend Mage_Catalog_Block_Product_View and override getJsonConfig as
public function getJsonConfig($_product = null, $configurable_id = null)
{
$_product = $_product? Mage::getModel('catalog/product')->load($_product->getId()) : $this->getProduct();
$config = array();
if (!$this->hasOptions()) {
return Mage::helper('core')->jsonEncode($config);
}