Posts Tagged ‘Magento’

tsl

Magento Custom List All Products Page

By Head Lounger • August 28th, 2010 • Magento Tags: , , ,

I had to make this update on a client’s site. I thought I’d share the code in case anyone has the same issue as I did. We needed to first all a “All Products” page in Magento, then have a particular category listed first. In this case the category was best selling items. The remaining list should display all the remaining products.

I ran through most of the Magento forum posts with little answers. There might be a better way to do this, but this uses a custom template page, CMS page, and the Product’s List.phtml.

1. First we create a new CMS page.
In our case, we called the page All Products. Keep note of your url key, you will use that to get to this new page. Click on the `Design` tab on the left to get to the Page’s layout xml. Here we will add:

<reference name="content">
    <block type="catalog/product_list"  name="product_list" template="customname/bestseller.phtml">
        <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
            <block type="page/html_pager" name="product_list_toolbar_pager"/>
        </block>
        <action method="setCategoryId"><category_id>2</category_id></action>
<action method="setColumnCount"><columns>4</columns></action>
        <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
    </block>
</reference> 

2. You will notice in the code above, template=”customname/bestseller.phtml”. This is where we specify the name of our template and the location of the file. We will create this file now. Create your new file “bestseller.phtml”. At the beginning of your page, add the following.

<?php
$visibility     = array(
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                  );

$storeId    = Mage::app()->getStore()->getId();

$_featcategory = Mage::getModel('catalog/category')->load(68);
 //replace 68 with the id of your featured category
$_productCollection = Mage::getResourceModel('catalog/product_collection')
                        ->addAttributeToSelect('*')
    			->addAttributeToFilter('visibility', $visibility)
		        ->setStoreId($storeId)
                        ->addStoreFilter($storeId)
    		        ->addCategoryFilter($_featcategory) //feature category to list first
			->setPageSize(12);	// number of products to list per page view
?>

3. The second half of your page will be a straight copy/paste of your list.phtml file. app/design/frontend/default/default/template/catalog/product/list.phtml. You will need to comment out the first line “// $_productCollection=$this->getLoadedProductCollection()”. Save the file and you are done.

4. Upload the new template to where you specified in step 1 template=”customname/bestseller.phtml”. You should now see an all products page with the featured category first. This has only been tested on the most recent version of Magento Community Ed. 1.4.0.1

 
tsl

Enable Soap with PHP5 On Media Temple (dv)

By Head Lounger • February 26th, 2010 • Web Servers Tags: , ,

So here we go again with another Media Temple Update. I currently moved my development server to Media Temple (dv). Everything so far has been pretty smooth. I had a Magento Cart to set up and needed SOAP enabled. Low and behold, Soap was not enabled on the server.

Note: If you are uncertain if your server has SOAP enabled or not, create a phpinfo(); file. If you do not see Soap enabled, you will need to add it.

Step 1: Download PHP5 (I am using version 5.2.6, so replace to whatever version you have). List of previous PHP versions.

wget http://museum.php.net/php5/php-5.2.6.tar.gz

Step 2: Unpack the PHP file
tar -zxf php-5.2.6.tar.gz

Step 3: Configure PHP to enable SOAP.
cd php-5.2.6
./configure --enable-soap=shared

Step 4: Rebuild PHP (This takes some time).
make

Step 5: Now we just copy over the SOAP module to your existing PHP module directory.
cp modules/soap.so /usr/lib/php/modules/

Step 6: Add the new SOAP configuration to your existing configuration
echo "extension=soap.so" > /etc/php.d/soap.ini

Step 7: Restart Server
/etc/init.d/httpd restart

Step 8: Remove the PHP folder you just downloaded for this process.
rm -rf /home/php-5.2.6/

Check your PHPINFO file again. You should now see soap enabled.
Cheers!

Special Thanks to dotjay.co.uk for pointing this out.

 
tsl

Magento Get Review URL

By Head Lounger • October 17th, 2009 • Magento Tags: , ,

My latest project is a Magento Shopping cart. Alot of this theme needed some custom features added, not in the code core already. The first of this was adding the Review Link outside of the summary review template. This used to be done by using the reviews helper. In the latest version of Magento, this no longer exists.  After digging through core files, I finally found the class that creates the review URL. I first noticed the getReviewURL() was returning the curent products link page and NOT the review form page. I am not sure if this is a bug or was done on purpose. So I added a  new method to the class so that I can call the Review URL.