<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brim</title>
	<atom:link href="http://www.brimllc.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brimllc.com</link>
	<description>streamlined software development</description>
	<lastBuildDate>Wed, 07 Mar 2012 18:30:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Magento &#8211; Fun with Debugging the Magento Compiler</title>
		<link>http://www.brimllc.com/2012/03/magento-fun-with-debugging-the-magento-compiler/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=magento-fun-with-debugging-the-magento-compiler</link>
		<comments>http://www.brimllc.com/2012/03/magento-fun-with-debugging-the-magento-compiler/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 17:07:03 +0000</pubDate>
		<dc:creator>Brian McGilligan</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[XDebug]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=474</guid>
		<description><![CDATA[I was recently debugging an issue with the Magento compiler that only seemed to occur when our Full Page Cache was enabled.  Drove me nuts for a good part of the day!  Basically when ever accessing the cart or one page checkout you would get a blank screen, just a white blank screen. So when [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I was recently debugging an issue with the <a class="zem_slink" title="Magento" href="http://www.magentocommerce.com" rel="homepage" target="_blank">Magento</a> compiler that only seemed to occur when our <a href="http://ecommerce.brimllc.com/performance/full-page-cache-magento.html">Full Page Cache</a> was enabled.  Drove me nuts for a good part of the day!  Basically when ever accessing the cart or one page checkout you would get a blank screen, just a white blank screen.</p>
<p>So when starting to look into this I did what I normally do and checked out the errors logs.  But what did I find &#8230; absolutely nothing!  Nothing in Magento&#8217;s, <a class="zem_slink" title="PHP-FPM" href="http://php-fpm.org/" rel="homepage" target="_blank">PHP-FPM</a>&#8216;s, or <a class="zem_slink" title="Nginx" href="http://www.nginx.org/" rel="homepage" target="_blank">Nginx</a>&#8216;s log files. I even checked the syslog just in case.  I went back and checked all my log settings.   Everything was fine but the blank screen persisted without generating any errors in the logs.  So I decided to turn on PHP&#8217;s display_errors setting as there obviously had to be an error of some sort causing this.  And it doesn&#8217;t get any easier than just displaying errors in the browser, right?  Nope still nothing, just a white blank screen&#8230;</p>
<p>So where to go from here?  I decided to checkout xdebug&#8217;s documentation in case there was something there to force a stack trace or something. I first found this and decided to give it a try:</p>
<blockquote>
<div>xdebug.show_exception_trace</div>
<p>Type: integer, Default value: 0</p>
<div>When this setting is set to 1, <a class="zem_slink" title="Xdebug" href="http://www.xdebug.org/" rel="homepage" target="_blank">Xdebug</a> will show a stack trace whenever an exception is raised &#8211; even if this exception is actually caught.</div>
</blockquote>
<p>I figured that should show something so I enabled it&#8230; but still nothing!  So went back searching through the documentation tried a few other things and then finally found this:</p>
<blockquote>
<div>xdebug.scream</div>
<p>Type: boolean, Default value: 0, Introduced in Xdebug 2.1</p>
<div>If this setting is 1, then Xdebug will disable the @ (shut-up) operator so that notices, warnings and errors are no longer hidden.</div>
</blockquote>
<p>And then finally something!</p>
<p style="text-align: center;"><a href="http://www.brimllc.com/wp-content/uploads/2012/03/fpc-compiler-exception.png" rel="lightbox"><img class="aligncenter  wp-image-481" title="fpc-compiler-exception" src="http://www.brimllc.com/wp-content/uploads/2012/03/fpc-compiler-exception.png" alt="FPC Compiler Exception" width="480" height="233" /></a></p>
<p>So as it turns out Xdebug&#8217;s scream setting can be really useful when you are at your wits end trying to find some error message that is hidden for what ever reason.  I found this to be an odd error at first but at least it&#8217;s something to work with.</p>
<p>What ended up causing the error in the first place and why was that exception displayed?  Well long story short Varien_Autoloader::registerScope was hiding all error messages on an include_once AWESOME!</p>
<pre>    static public function registerScope($code)
    {
        self::$_scope = $code;
        if (defined('COMPILER_INCLUDE_PATH')) {
            @include_once self::SCOPE_FILE_PREFIX.$code.'.php';
        }
    }</pre>
<p>But why the redeclare?  It&#8217;s kind of an odd exception to get.  Well, we were hooking into Magento&#8217;s controller_action_predispatch event, loading some classes, and doing a few checks.  However controller_action_predispatch occurs before Magento registers the current scope which in this case was &#8220;checkout&#8221;.  The Magento compiler uses this scope concept to combine known required classes into a single file to cut down on the number of include_once that are needed.  Less file access is needed so it should make IO on the disk a little lighter.</p>
<p>Since Mage_Directory_Model_Currency is defined in Mage_Directory_Model_Currency.php and __checkout.php and we needed the class before the auto loader registered the scope we ended up with a redeclared class.   So that was my fun with debugging the Magento compiler.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><img class="zemanta-pixie-img" style="float: right;" src="http://img.zemanta.com/pixy.gif?x-id=7bc9a180-5ee0-479e-9bf8-402af9ce4b82" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2012/03/magento-fun-with-debugging-the-magento-compiler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails &#8211; groovy.lang.MissingPropertyException: No such property: name for class:  java.lang.Object</title>
		<link>http://www.brimllc.com/2012/01/grails-groovy-lang-missingpropertyexception-no-such-property-name-for-class-java-lang-object/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=grails-groovy-lang-missingpropertyexception-no-such-property-name-for-class-java-lang-object</link>
		<comments>http://www.brimllc.com/2012/01/grails-groovy-lang-missingpropertyexception-no-such-property-name-for-class-java-lang-object/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 23:29:24 +0000</pubDate>
		<dc:creator>tmillhouse</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=458</guid>
		<description><![CDATA[After adding a custom Comparator to sort one of my domain models, I started getting the following exception sporadically: groovy.lang.MissingPropertyException: No such property: name for class: java.lang.Object The odd thing is that the model I was attempting to sort was one of my domain models of type Transaction; however, grails was interpreting it as a [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>After adding a custom Comparator to sort one of my domain models, I started getting the following exception sporadically:</p>
<p>groovy.lang.MissingPropertyException: No such property: name for class:<br />
java.lang.Object</p>
<p>The odd thing is that the model I was attempting to sort was one of my domain models of type Transaction; however, grails was interpreting it as a generic Object. The really weird thing is that it was also interpreting my Transaction objects as generic Objects in other locations as well. After a while of debugging, I went back to the code where I started seeing the issue. I had created a private inner class for the Comparator and defined it as follows:</p>
<p><code><br />
private class TransactionComparator&lt;Transaction&gt; extends Comparator&lt;Transaction&gt;</p>
<p>...<br />
</code></p>
<p>My mistake was including the generic declaration at the class level. This would be invalid in normal Java syntax; however, groovy was compiling another class named Transaction, but it was casting it to a generic Object. Once I fixed my class to the following, the issue went away:</p>
<p><code><br />
private class TransactionComparator extends Comparator&lt;Transaction&gt;</p>
<p>...<br />
</code></p>
<p>I hope this helps others that run into similar issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2012/01/grails-groovy-lang-missingpropertyexception-no-such-property-name-for-class-java-lang-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails &#8211; CXF Web Service with MTOM Attachments</title>
		<link>http://www.brimllc.com/2012/01/grails-cxf-web-service-with-mtom-attachments/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=grails-cxf-web-service-with-mtom-attachments</link>
		<comments>http://www.brimllc.com/2012/01/grails-cxf-web-service-with-mtom-attachments/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 19:24:58 +0000</pubDate>
		<dc:creator>tmillhouse</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=456</guid>
		<description><![CDATA[I&#8217;m writing this mostly for my own reference, but I thought it would be helpful to others as well. I&#8217;ve been working a lot lately with integrating CXF into grails via the CXF-grails plugin; however, while enabling MTOM to allow SOAP attachments, I ran into a few issues that I had to work around. The [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I&#8217;m writing this mostly for my own reference, but I thought it would be helpful to others as well. I&#8217;ve been working a lot lately with integrating CXF into grails via the CXF-grails plugin; however, while enabling MTOM to allow SOAP attachments, I ran into a few issues that I had to work around. The following are the steps I took to successfully allow uploading files via my web service:</p>
<h2>1. Enable MTOM on the service</h2>
<p><code><br />
	@MTOM(enabled = true)<br />
	@javax.jws.WebService(<br />
	serviceName = "MyWebService",<br />
	portName = "MyWebService",<br />
	targetNamespace = "http://test.brimllc.com",<br />
	endpointInterface = "com.brimllc.ws.MyWebServiceInterface")<br />
	class MyWebService ...<br />
</code></p>
<h2>2. Add the MIME type to the DataHandler request object.</h2>
<p>This step allows the binding of the incoming attachment to the bean field.</p>
<p><code><br />
	// ... some request bean<br />
	@XmlMimeType("application/octet-stream")<br />
	private DataHandler fileData;<br />
</code></p>
<h2>3. Exclude the &#8216;/services&#8217; path from UrlMappings.groovy. </h2>
<p>Without this step, the default grails URL interceptor will process the request as a file upload, which in turn will read the InputStream, causing the CXF interceptor to have an empty stream.</p>
<p><code><br />
	static excludes = ['/services*']<br />
</code></p>
<h2>4. Remove mail.jar &#038; activation.jar from the classpath in BuildConfig.groovy</h2>
<p>My project is using the mail plugin, which manually copies over these jars from it&#8217;s /lib folder. One of the CXF interceptors will throw an error since the classes contained within these jars has already been loaded by the servlet containers classpath.</p>
<p><code><br />
	grails.war.resources = { stagingDir, args -><br />
		println "Removing mail.jar and activation.jar from WEB-INF/lib/"<br />
		delete(file: "${stagingDir}/WEB-INF/lib/mail.jar")<br />
		delete(file: "${stagingDir}/WEB-INF/lib/activation.jar")<br />
	}<br />
</code></p>
<p>Now, your grails-cxf web service should be able to properly process an incoming MTOM SOAP message. One thing to note is that you may need to extend and modify the LoggingInInterceptor since it doesn&#8217;t know how to properly log the incoming messages with multiple boundaries. I can provide examples of this as well if anyone is interested. I&#8217;ve tested my service using SoapUI as a SOAP client. SoapUI allows you to specify MTOM settings on your test requests as well as adding attachments.</p>
<p>I&#8217;ve done a lot more work with Grails-CXF integration, so if there are other topics that anyone is interested in, email me and let me know. (devs@brimllc.com)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2012/01/grails-cxf-web-service-with-mtom-attachments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache CXF Client- Setting Http Request Header for Basic Authentication</title>
		<link>http://www.brimllc.com/2011/04/apache-cxf-client-setting-http-request-header-for-basic-authentication/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apache-cxf-client-setting-http-request-header-for-basic-authentication</link>
		<comments>http://www.brimllc.com/2011/04/apache-cxf-client-setting-http-request-header-for-basic-authentication/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 18:55:54 +0000</pubDate>
		<dc:creator>Yagish Sharma</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=436</guid>
		<description><![CDATA[While setting up Test Driven Development environment with Apache CXF, I came across a small issue with creating a JUnit client, which will add the Basic Authentication info in the Http Request Header before sending the request. I found couple of ways to do this using JAXWS, but wanted to stick with Apache CXF. On [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>While setting up Test Driven Development environment with Apache CXF, I came across a small issue with creating a JUnit client, which will add the Basic Authentication info in the Http Request Header before sending the request. I found couple of ways to do this using <a href="http://www.mkyong.com/webservices/jax-ws/application-authentication-with-jax-ws/">JAXWS</a>, but wanted to stick with Apache CXF.<br />
 On the Server side, I was using Spring Security which was not so tricky to configure. To add the header info, I needed to create an &#8220;Interceptor&#8221;, which will intercept the message before it is &#8220;marshalled&#8221;. Here is the code -</p>
<pre>
 <code>
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.codec.binary.Base64;
import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.Phase;
import org.springframework.beans.factory.annotation.Required;
 public class BasicAuthenticationHeaderGeneratorInterceptor extends
		AbstractOutDatabindingInterceptor {
	public static final String COLON = ":";
	public static final String SPACE = " ";
	public static final String BASIC = "Basic";
	/** Map of allowed users to this system with their corresponding passwords. */
	private Map users;

	@Required
	public void setUsers(Map users) {
		this.users = users;
	}

	public BasicAuthenticationHeaderGeneratorInterceptor() {
		super(Phase.MARSHAL);
	}

	public BasicAuthenticationHeaderGeneratorInterceptor(String phase) {
		super(phase);
	}

	public void handleMessage(Message outMessage) throws Fault {
		Map&lt;String, List&gt; headers = (Map&lt;String, List&gt;) outMessage
				.get(Message.PROTOCOL_HEADERS);
		try {
			headers.put("Authorization", Collections.singletonList(BASIC
					+ SPACE + getBase64EncodedCredentials().trim()));
		} catch (Exception ce) {
			throw new Fault(ce);
		}
	}

	private String getBase64EncodedCredentials(){
		String userName = null;
		String password = null;
		Iterator iterator = null != users ? users.keySet().iterator()
				: null;
		if (null != iterator &amp;&amp; iterator.hasNext()) {
			userName = iterator.next();
			password = users.get(userName);
		}
		String clearCredentials = userName + COLON + password;
		return new String(Base64.encodeBase64(clearCredentials.getBytes()));
	}
}
</code>
</pre>
<p>Here is the interceptor configuration in application-context.xml -</p>
<pre>
 <code>
  &lt;cxf:bus&gt;
		&lt;cxf:outInterceptors&gt;
			&lt;ref bean="basicAuthenticationHeaderGenerator" /&gt;
		&lt;/cxf:outInterceptors&gt;
  &lt;/cxf:bus&gt;

  &lt;bean id="basicAuthenticationHeaderGenerator"
	class="com.blah.interceptor.BasicAuthenticationHeaderGeneratorInterceptor"&gt;
		&lt;property name="users"&gt;
			&lt;map&gt;
				&lt;entry key="abc" value="dev" /&gt;
			&lt;/map&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
</code>
</pre>
<p> I preferred this implementation over JAXWS, since it works great with Spring Test and Apache CXF, without having to use JAXWS API. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2011/04/apache-cxf-client-setting-http-request-header-for-basic-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>a4j:jsFunction in IE6/7 breaks when html:form&#8217;s prependId=&#8221;false&#8221;</title>
		<link>http://www.brimllc.com/2011/04/a4jjsfunction-in-ie67-breaks-when-htmlforms-prependidfalse/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a4jjsfunction-in-ie67-breaks-when-htmlforms-prependidfalse</link>
		<comments>http://www.brimllc.com/2011/04/a4jjsfunction-in-ie67-breaks-when-htmlforms-prependidfalse/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 18:36:01 +0000</pubDate>
		<dc:creator>Yagish Sharma</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=424</guid>
		<description><![CDATA[I wrote this article in JBoss Community. Here is another version of the same article. It is useful, when porting existing application from Ajax4JSF to use RichFaces. In RichFaces3.2.2SR1, a4j:jsFunction generates an HTML script, which breaks in IE6/7, but works in FireFox. The issue is the way the jsFunction is rendered. Here is a sample [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I wrote this article in <a href="http://community.jboss.org/thread/13631">JBoss Community</a>. Here is another version of the same article. It is useful, when porting existing application from Ajax4JSF to use RichFaces.</p>
<p>In RichFaces3.2.2SR1, a4j:jsFunction generates an HTML script, which breaks in IE6/7, but works in FireFox. The issue is the way the jsFunction is rendered.</p>
<p>Here is a sample of how the script is rendered in Ajax4JSF and in RichFaces when html:form&#8217;s prependId attribute is false.</p>
<p>Notice that the name and id fields are kept same.</p>
<p>In Ajax4JSF, this will render as -</p>
<pre><code>
script id="func1" type="text/javascript"
function func1(){.........};
/script
</code></pre>
<p>In RichFaces, this renders as -</p>
<pre><code>
script id="func1" type="text/javascript"&gt;
func1 = function(){.........};
/script
</code></pre>
<p>Having the &#8220;id&#8221; of script tag and the func1 prototype &#8220;name&#8221; as same creates the problem. IE6/7 while parsing the script tag gives an error &#8211; &#8220;Object does not supports this property&#8221;.</p>
<p>In RichFaces the renderer for jsFunction is AjaxFunctionRendererBase. This renderer&#8217;s getFunction() method has changed from Ajax4JSF and generates this inappropriate javascript code.</p>
<p>A simple fix would be to set html:form&#8217;s prependId=&#8221;true&#8221;, which will append the form&#8217;s name to the &#8220;id&#8221; attribute, and the name and id will be different. There is a catch, in an existing application, then u will have to change all the javascript which uses the &#8220;id&#8221; to find the element. </p>
<p>The real fix would be to change the AjaxFunctionRenderer of RichFaces. Actually, its more like a workaround. If you are creating a new application from scratch, and using RichFaces, i will still use the RichFaces version.<br />
Here is how to do it -<br />
Create a new class extending the FunctionRenderer in RichFaces, and over-ride the getFunction method -</p>
<pre><code>
public class NewAjaxFunctionRenderer extends FunctionRenderer{
 /*
 * (non-Javadoc)
 *
 * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
 */

 public static final String RENDERER_TYPE = "org.abc.AjaxFunctionRenderer";
 protected Class getComponentClass() {
 return HtmlAjaxFunction.class;
 }

 public String getFunction(FacesContext context, UIAjaxFunction component) {
 StringBuffer script = new StringBuffer();
 JSFunctionDefinition func = new JSFunctionDefinition();
 func.setName(component.getName());
 // Create AJAX Submit function.
 JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
 component, context,AjaxRendererUtils.AJAX_FUNCTION_NAME);
 Map options = AjaxRendererUtils.buildEventOptions(context, component);
 Map parameters = (Map) options.get("parameters");
 if (null == parameters) {
 parameters = new HashMap();
 options.put("parameters", parameters);
 }
 ajaxFunction.addParameter(JSReference.NULL);
 ajaxFunction.addParameter(options);
 // Fill parameters.
 for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
 UIComponent child = (UIComponent) it.next();
 if (child instanceof UIParameter) {
 UIParameter parameter = ((UIParameter) child);
 String name = parameter.getName();
 func.addParameter(name);
 // Put parameter name to AJAX.Submit parameter, with default value.
 JSReference reference = new JSReference(name);
 if (null != parameter.getValue()) {
 reference = new JSReference(name + "||"
 + ScriptUtils.toScript(parameters.get(name)));

 }
 // Replace parameter value to reference.
 parameters.put(name, reference);
 }
 }
 func.addToBody(ajaxFunction.toScript());
 func.appendScript(script);
 return script.toString();
 }
}
</code></pre>
<p>In faces-config.xml add the new renderer for a4j:jsFunction &#8211; </p>
<pre><code>

 &lt;renderer&gt;
 &lt;component-family&gt;org.ajax4jsf.components.AjaxFunction&lt;/component-family&gt;
 &lt;renderer-type&gt;
 org.ajax4jsf.components.AjaxFunctionRenderer
 &lt;/renderer-type&gt;
 &lt;renderer-class&gt;
 org.test.NewAjaxFunctionRenderer
 &lt;/renderer-class&gt;
 &lt;/renderer&gt;

</code></pre>
<p> The tricky part is to find the component-family and renderer-type for AjaxFunctionRenderer. You can explode the richfaces jar and search the faces-config.xml to look for component-family and renderer-type for AjaxFunctionRenderer. Once you have it, this can be easily over-ridden in your application&#8217;s faces-config.xml as listed above.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2011/04/a4jjsfunction-in-ie67-breaks-when-htmlforms-prependidfalse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento &#8211; Accessing Custom Product Attributes in the Cart/Checkout Area</title>
		<link>http://www.brimllc.com/2011/04/magento-accessing-custom-product-attributes-in-the-cartcheckout-area/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=magento-accessing-custom-product-attributes-in-the-cartcheckout-area</link>
		<comments>http://www.brimllc.com/2011/04/magento-accessing-custom-product-attributes-in-the-cartcheckout-area/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 17:38:52 +0000</pubDate>
		<dc:creator>tmillhouse</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=420</guid>
		<description><![CDATA[For some reason, I always tend to run into this problem and I forgot the solution I previously implemented. Sometimes, you Magento site will have custom product attributes that you&#8217;d like to be viewable from the cart/checkout areas. For performance reasons, the product available to the order/quote doesn&#8217;t contain all of the attributes. Instead of [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>For some reason, I always tend to run into this problem and I forgot the solution I previously implemented. Sometimes, you Magento site will have custom product attributes that you&#8217;d like to be viewable from the cart/checkout areas. For performance reasons, the product available to the order/quote doesn&#8217;t contain all of the attributes. </p>
<p>Instead of querying the product new to retrieve the attributes, you can instead define what attributes you&#8217;d like to be loaded during the cart/checkout process within the a config.xml file. The structure will be as follows:</p>
<p>&lt;sales&gt;<br />
&lt;quote&gt;<br />
&lt;item&gt;<br />
&lt;product_attributes&gt;</p>
<p>&lt;your_attribute_1/&gt;<br />
&lt;your_attribute_2/&gt;</p>
<p>&lt;/product_attributes&gt;<br />
&lt;/item&gt;<br />
&lt;quote&gt;<br />
&lt;sales&gt;</p>
<p>Maybe this will save some others time as well&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2011/04/magento-accessing-custom-product-attributes-in-the-cartcheckout-area/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento &#8211; Automate the Creation of Additional/Custom Category Attributes</title>
		<link>http://www.brimllc.com/2011/03/magento-automate-the-creation-of-additionalcustom-category-attributes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=magento-automate-the-creation-of-additionalcustom-category-attributes</link>
		<comments>http://www.brimllc.com/2011/03/magento-automate-the-creation-of-additionalcustom-category-attributes/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 20:33:35 +0000</pubDate>
		<dc:creator>tmillhouse</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=416</guid>
		<description><![CDATA[If you search the net for how to add new custom attributes to categories, you&#8217;ll find many sites that define the steps in manual SQL inserts. The issue I found was that most of these sites are specific to Magento versions previous to 1.4/Enterprise 1.9 and leave out a crucial step. Also, I find it [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>If you search the net for how to add new custom attributes to categories, you&#8217;ll find many sites that define the steps in manual SQL inserts. The issue I found was that most of these sites are specific to Magento versions previous to 1.4/Enterprise 1.9 and leave out a crucial step. Also, I find it to be bad practice to manually insert rows into your Magento database because it makes it hard to deploy across environments.</p>
<p>The general approach to create custom category attributes is the following 3 SQL inserts:</p>
<pre><code>INSERT INTO `eav_attribute` (
				`attribute_id` ,
				`entity_type_id` ,
				`attribute_code` ,
				`attribute_model` ,
				`backend_model` ,
				`backend_type` ,
				`backend_table` ,
				`frontend_model` ,
				`frontend_input` ,
				`frontend_label` ,
				`frontend_class` ,
				`source_model` ,
				`is_required` ,
				`is_user_defined` ,
				`default_value` ,
				`is_unique` ,
				`note`
	)
	VALUES (
			NULL ,  '3',  'header_image', NULL ,  'catalog/category_attribute_backend_image',  'varchar', NULL , NULL ,  'image',  'Header Image', NULL , NULL ,  '0',  '0', NULL ,  '0',  ''
	);

	SET @attribute_id = LAST_INSERT_ID();

	INSERT INTO `eav_entity_attribute` (
				`entity_attribute_id` ,
				`entity_type_id` ,
				`attribute_set_id` ,
				`attribute_group_id` ,
				`attribute_id` ,
				`sort_order`
	)
	VALUES (
		NULL ,  '3',  '3',  '3',  @attribute_id,  '30'
	);

	INSERT INTO `catalog_eav_attribute` (
				`attribute_id` ,
				`frontend_input_renderer` ,
				`is_global` ,
				`is_visible` ,
				`is_searchable` ,
				`is_filterable` ,
				`is_comparable` ,
				`is_visible_on_front` ,
				`is_html_allowed_on_front` ,
				`is_used_for_price_rules` ,
				`is_filterable_in_search` ,
				`used_in_product_listing` ,
				`used_for_sort_by` ,
				`is_configurable` ,
				`apply_to` ,
				`is_visible_in_advanced_search` ,
				`position` ,
				`is_wysiwyg_enabled`
	)
	VALUES (
		@attribute_id, NULL ,  '1',  '1',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '1',  '',  '0',  '',  '0'
	);</code></pre>
<p>The above code is specific to one of my Magento installs, which in this case I&#8217;m creating a custom image attribute. You can create any sort of attribute by identifying a similar attribute and copying most of the columns.</p>
<p>Now, this alone will give you your custom attribute, and if you only have one environment, this may be sufficient. Most projects, however, have development, test, and production environments, and if you manually insert SQL, it can be hard to ensure data consistency. </p>
<p>For this reason, its good practice to create a custom module where you can create a sql setup script that will automatically run and insert your desired columns. For my project, I created a module called Brim_Catalog with the following folder hierarchy:</p>
<p>-app<br />
    &#8211; code<br />
        &#8211; local<br />
            &#8211; Brim<br />
                &#8211; Catalog<br />
                    &#8211; etc (create a config.xml file here)<br />
                    &#8211; sql<br />
                        &#8211; brim_catalog_setup (create a mysql-install-0.1.0.php here)</p>
<p>Now, in your config.xml, create the following resource declaration:</p>
<pre>
<code>
&lt;resources>
            &lt;brim_catalog_setup&gt;
                &lt;setup&gt;
                    &lt;module&gt;Brim_Catalog&lt;/module&gt;
                &lt;/setup&gt;
                &lt;connection&gt;
                    &lt;use>core_setup&lt;/use&gt;
                &lt;/connection&gt;
            &lt;/brim_catalog_setup&gt;
        &lt;/resources&gt;
</code>
</pre>
<p>Finally, you can define your SQL in the mysql-install-0.1.0.php file as such:</p>
<pre>
<code>

<?php

$installer = $this;

$installer->startSetup();

// create a new category attribute 'header_image' to display as the header on category landing pages
$installer->run("
	INSERT INTO `eav_attribute` (
				`attribute_id` ,
				`entity_type_id` ,
				`attribute_code` ,
				`attribute_model` ,
				`backend_model` ,
				`backend_type` ,
				`backend_table` ,
				`frontend_model` ,
				`frontend_input` ,
				`frontend_label` ,
				`frontend_class` ,
				`source_model` ,
				`is_required` ,
				`is_user_defined` ,
				`default_value` ,
				`is_unique` ,
				`note`
	)
	VALUES (
			NULL ,  '3',  'header_image', NULL ,  'catalog/category_attribute_backend_image',  'varchar', NULL , NULL ,  'image',  'Header Image', NULL , NULL ,  '0',  '0', NULL ,  '0',  ''
	);

	SET @attribute_id = LAST_INSERT_ID();

	INSERT INTO `eav_entity_attribute` (
				`entity_attribute_id` ,
				`entity_type_id` ,
				`attribute_set_id` ,
				`attribute_group_id` ,
				`attribute_id` ,
				`sort_order`
	)
	VALUES (
		NULL ,  '3',  '3',  '3',  @attribute_id,  '30'
	);

	INSERT INTO `catalog_eav_attribute` (
				`attribute_id` ,
				`frontend_input_renderer` ,
				`is_global` ,
				`is_visible` ,
				`is_searchable` ,
				`is_filterable` ,
				`is_comparable` ,
				`is_visible_on_front` ,
				`is_html_allowed_on_front` ,
				`is_used_for_price_rules` ,
				`is_filterable_in_search` ,
				`used_in_product_listing` ,
				`used_for_sort_by` ,
				`is_configurable` ,
				`apply_to` ,
				`is_visible_in_advanced_search` ,
				`position` ,
				`is_wysiwyg_enabled`
	)
	VALUES (
		@attribute_id, NULL ,  '1',  '1',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '1',  '',  '0',  '',  '0'
	);
");

$installer->endSetup();
</code>
</pre>
<p>That&#8217;s all there is to it. Now, every environment that you deploy your code to will be guaranteed to have the same custom category attributes. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2011/03/magento-automate-the-creation-of-additionalcustom-category-attributes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Magento : Getting a Product&#8217;s Manufacturer Name instead ID</title>
		<link>http://www.brimllc.com/2011/02/magento-getting-a-products-manufacturer-name-instead-id/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=magento-getting-a-products-manufacturer-name-instead-id</link>
		<comments>http://www.brimllc.com/2011/02/magento-getting-a-products-manufacturer-name-instead-id/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 11:25:22 +0000</pubDate>
		<dc:creator>Brian McGilligan</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=406</guid>
		<description><![CDATA[If you have every done this: $_product = Mage::getModel('catalog/product')->load(__PRODUCT_ID__); $manufacturer = $_product->getManufacturer(); You&#8217;ll know that you get the manufacturer&#8217;s id instead of it&#8217;s name. Which may or may not be what you would have expected. But the product model provides a nice helper method for getting an attributes value, in case it was not what [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>If you have every done this:</p>
<p><code><br />
$_product = Mage::getModel('catalog/product')->load(__PRODUCT_ID__);<br />
$manufacturer = $_product->getManufacturer();<br />
</code></p>
<p>You&#8217;ll know that you get the manufacturer&#8217;s id instead of it&#8217;s name.  Which may or may not be what you would have expected.  But the product model provides a nice helper method for getting an attributes value, in case it was not what you were expecting.  Below is the code to get a product&#8217;s manufacturer name instead of it&#8217;s ID.</p>
<p><code><br />
$_product = Mage::getModel('catalog/product')->load(__PRODUCT_ID__);<br />
$manufacturer = $_product->getAttributeText('manufacturer');<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2011/02/magento-getting-a-products-manufacturer-name-instead-id/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery &#8211; How to Invoke an Object&#8217;s Fields Within a Function Closure</title>
		<link>http://www.brimllc.com/2011/02/jquery-how-to-invoke-an-objects-fields-within-a-function-closure/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jquery-how-to-invoke-an-objects-fields-within-a-function-closure</link>
		<comments>http://www.brimllc.com/2011/02/jquery-how-to-invoke-an-objects-fields-within-a-function-closure/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 19:53:14 +0000</pubDate>
		<dc:creator>tmillhouse</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=403</guid>
		<description><![CDATA[This may be common knowledge for many, but since I go back and forth between jQuery and Prototype, I find myself always researching how each Javascript frameworks handle context switching. A frequent problem I run into is having a custom Javascript object who has a function that contains a function closure that tries to call [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This may be common knowledge for many, but since I go back and forth between jQuery and Prototype, I find myself always researching how each Javascript frameworks handle context switching. A frequent problem I run into is having a custom Javascript object who has a function that contains a function closure that tries to call the object itself (that&#8217;s a lot to take in). Lets look at an example &#8230;</p>
<p>Suppose we have the following jQuery Javascript class:</p>
<pre><code>
var SomeObj= function() {
	this.init();
}
$.extend(SomeObj.prototype, {
        init: function(){
             $('button').click(function(index){
                  // I'd like to call this.someMethod();
             });
        },
        someMethod: function(){
            alert('Hello World!');
        }
});

</code></pre>
<p>In the code above, I can&#8217;t just call &#8216;this.someMethod()&#8217; within the function closure due to the context at which it will be executed. At the time the code is run, &#8216;this&#8217; will be set to the button who fires the event. If we want to call a method or field on the custom javascript object, we have to cache its instance within a local variable. If we modify the code as below, it will now work:</p>
<pre><code>
var SomeObj= function() {
	this.init();
}
$.extend(SomeObj.prototype, {
        init: function(){
             var self = this;
             $('button').click(function(index){
                  self.someMethod();
             });
        },
        someMethod: function(){
            alert('Hello World!');
        }
});

</code></pre>
<p>Now, lets not get all bothered over semantics. I know that the above example is not a real-world example of anything useful; however, the approach I&#8217;ve taken may prove helpful for someone in a different scenario.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2011/02/jquery-how-to-invoke-an-objects-fields-within-a-function-closure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy Google Chart Encoding Script</title>
		<link>http://www.brimllc.com/2011/01/groovy-google-chart-encoding-script/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=groovy-google-chart-encoding-script</link>
		<comments>http://www.brimllc.com/2011/01/groovy-google-chart-encoding-script/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 19:02:00 +0000</pubDate>
		<dc:creator>tmillhouse</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Grails]]></category>

		<guid isPermaLink="false">http://www.brimllc.com/?p=394</guid>
		<description><![CDATA[I&#8217;ve been playing around with Google Chart integration into a new Grails application, and while teaching myself the chart data formats, I converted the javascript data encoding script to Groovy. This hasn&#8217;t been tested thoroughly, but its been working nicely for me in my project. /** * See http://code.google.com/apis/chart/docs/data_formats.html#extended */ class GoogleChartUtil { private static [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I&#8217;ve been playing around with Google Chart integration into a new Grails application, and while teaching myself the chart data formats, I converted the <a href="http://code.google.com/apis/chart/docs/data_formats.html">javascript data encoding script</a> to Groovy. This hasn&#8217;t been tested thoroughly, but its been working nicely for me in my project.</p>
<p><code><br />
/**<br />
 * See http://code.google.com/apis/chart/docs/data_formats.html#extended<br />
 */<br />
class GoogleChartUtil {</p>
<p>	private static final String simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';</p>
<p>	// This function scales the submitted values so that<br />
	// maxVal becomes the highest value.<br />
	static simpleEncode(valueArray,maxValue) {<br />
		def chartData = ['s:'];<br />
		for (int i = 0; i < valueArray.size(); i++) {<br />
			def currentValue = valueArray[i];<br />
			if (currentValue >= 0) {<br />
				chartData.push(simpleEncoding.charAt((int) Math.round((simpleEncoding.length()-1) *<br />
						currentValue / maxValue)));<br />
			}<br />
			else {<br />
				chartData.push('_');<br />
			}<br />
		}<br />
		return chartData.join('');<br />
	}</p>
<p>	private static final String EXTENDED_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.';<br />
	private static final int EXTENDED_MAP_LENGTH = EXTENDED_MAP.length();</p>
<p>	static extendedEncode(arrVals, maxVal) {<br />
		def chartData = 'e:';</p>
<p>		int len = arrVals.size();<br />
		for(int i = 0; i < len; i++) {<br />
			// In case the array vals were translated to strings.<br />
			def numericVal = new Float(arrVals[i]);<br />
			// Scale the value to maxVal.<br />
			def scaledVal = Math.floor(EXTENDED_MAP_LENGTH *<br />
					EXTENDED_MAP_LENGTH * numericVal / maxVal);</p>
<p>			if(scaledVal > (EXTENDED_MAP_LENGTH * EXTENDED_MAP_LENGTH) - 1) {<br />
				chartData += "..";<br />
			} else if (scaledVal < 0) {<br />
				chartData += '__';<br />
			} else {<br />
				// Calculate first and second digits and add them to the output.<br />
				def quotient = Math.floor(scaledVal / EXTENDED_MAP_LENGTH);<br />
				def remainder = scaledVal - EXTENDED_MAP_LENGTH * quotient;<br />
				chartData += EXTENDED_MAP.charAt((int)quotient) + EXTENDED_MAP.charAt((int)remainder);<br />
			}<br />
		}</p>
<p>		return chartData;<br />
	}<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.brimllc.com/2011/01/groovy-google-chart-encoding-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
