josephbill.com

Modifying Magento TheFind Module To Actually Work

with 5 comments

There are a number of features that are included with Magento (I am currently using 1.5.1) but don’t work out of the box. As I am starting to learn, Magento is known for adding new bugs for every new release. One of those new bugs I believe was added to TheFind.

I got TheFind configured by following the great directions here. Then I published all of my products to TheFind but it wasn’t working cause I was getting an error about the product and image URLs. So I downloaded the feed from TheFind through FTP and I noticed the product URLs and image URLs are relative. There’s probably a better solution to this but I don’t have a lot of time so I came up with something as quick as I could.

So here is what you need to do:

1. Configure TheFind by following the steps here.

2. Change this line in /app/code/community/Find/Feed/Model/Import.php:

111
112
113
foreach ($attributes as $key => $value) {
    $attributesRow[$key] = $product->getData($value);
}

To this:

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
$image_count = Mage::getModel('catalog/product')->load($product->getId())->getMediaGalleryImages()->count(); 
 
if($image_count == 0)
{
    continue;	
}
 
foreach ($attributes as $key => $value) {
    if($key == "Page_Url" || $key == "Image_Link" || $key == "Brand" || $key == "Condition")
    {
        switch($key)
        {
            case "Page_Url":
                $value = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . $product->getUrlPath();
                break;
            case "Image_Link":
                $value = $product->getImageUrl();
                break;
            case "Brand":
                $value = $product->getAttributeText('manufacturer');
                break;
            case "Condition":
                $value = $product->getAttributeText('condition');
                break;
        }
 
        $attributesRow[$key] = $value;
    }
    else
    {
        $attributesRow[$key] = $product->getData($value);
    }
}

You can also download the file here: Import.zip

You will notice that I am including manufacturer and condition, not because they are required, but because it’s always better to include as many attributes as possible to get better rankings (at least that is the way it is with Google). These attributes were appearing as IDs instead of their text versions. You may also notice that I am checking to see if an image exists since TheFind requires them and I was getting an error from products that don’t have images.

Want to learn how to get free traffic from Google to your Magento store? Checkout The Keyword Academy, the place that taught me how to make $50k/year with free Google traffic. Contact me here if you’d like to learn more.

Written by Joe

September 6th, 2011 at 8:03 am

Posted in Magento,Programming

Tagged with ,