Magento reviews on category page

I wanted to make my category page look even, so everything was the same height, my main problem with that was that I displayed reviews on the category page. The problem with this is that if a product didn’t have a review it didn’t show anything. My solution was to add the following lines of code to list.phtml in the catalog template files

<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, ‘short’) ?>
<?php else: ?>
<p align=”center”><a href=”<?php echo $_product->getProductUrl() ?>#product_tabs_review_tabbed” title=”<?php echo $this->stripTags($_product->getName(), null, true) ?>”>Be the first to review</a></p>
<?php endif; ?>

This then presented me with another problem, for some products it displayed “be the first to review”  and for some it didn’t, I checked what displayed and what didn’t and it appeared that products displayed “be the first to review” if they were created after an upgrade from 1.7 to 1.8 so a quick search of the database. I found that if you go to review_entity_summary and clear out any entries that have a review_count of 0 they will then all display.

Moz API PHP connection

Im currently developing some new reporting functionality and as part of this I need to pull certain data from a quick look at there API and its fairly easy to do this using PHP.

First of all you need to have a look at there API reference you particularly need to work out with flag bits you use and then add them up.

I then used this code to connect to the API and return the data I wanted


// Obtain your access id and secret key here:
$accessID = “member-XXXXXXXX”;

// Set your expires for five minutes into the future.
$expires = time() + 300;

// A new linefeed is necessary between your AccessID and Expires.
$stringToSign = $accessID.”\n”.$expires;

// Get the “raw” or binary output of the hmac hash.
$binarySignature = hash_hmac(‘sha1’, $stringToSign, $secretKey, true);

// We need to base64-encode it and then url-encode that.
$urlSafeSignature = urlencode(base64_encode($binarySignature));

// This is the URL that we want link metrics for.
$objectURL = “”;

// Add up all the bit flags you want returned.
// Learn more here:
$cols = “81604388192”;

// Now put your entire request together.
// This example uses the Mozscape URL Metrics API.
$requestUrl = “”.urlencode($objectURL).”?Cols=”.$cols.”&AccessID=”.$accessID.”&Expires=”.$expires.”&Signature=”.$urlSafeSignature;

// We can easily use Curl to send off our request.
$options = array(

$ch = curl_init($requestUrl);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
// * Store URL metrics in array

$json_a = json_decode($content);

// * Assign URL metrics to separate variables

$pageAuthority = round($json_a->upa,0); // * Use the round() function to return integer
$domainAuthority = round($json_a->pda,0);
$externalLinks = $json_a->puid;
$subLinks = $json_a->fuid;
$equityLinks = $json_a->ujid;
$ExtequityLinks = $json_a->ueid;
$SubequityLinks = $json_a->feid;
$rootdomainsLinks = $json_a->uipl;
$rootLinks = $json_a->pid;
$theUrl = $json_a->uu;

<title>Moz API Feed for reporting</title>
<h1>Moz API Feed for reporting</h1>

<li><strong>Domain Authority:</strong> <?php echo $domainAuthority; ?></li>
<li><strong>Links to Root Domain:</strong> <?php echo $externalLinks; ?></li>
<li><strong>Links to Subdomain:</strong> <?php echo $subLinks; ?></li>
<li><strong>Equity Links:</strong> <?php echo $equityLinks; ?></li>
<li><strong>External Equity Links:</strong> <?php echo $ExtequityLinks; ?></li>
<li><strong>Subdomain External Links:</strong> <?php echo $SubequityLinks; ?></li>
<li><strong>Root Domains Linking:</strong> <?php echo $rootdomainsLinks; ?></li>
<li><strong>Root Domain, Root Domains Linking:</strong> <?php echo $rootLinks; ?></li>

Magento Google Tag Manager Ecommerce

This one took a while to figure out and get it reporting correctly, the idea of Google Tag Manager is to make things easier – I’m not convinced!

Firstly you need to install this plugin from Magento Connect

You need to use this one as its the only one that has the data layer support that you need (after a little tweaking)

Once installed in the configuration make sure that Data layer: Transactions is enabled

Go to the file


Find protected function _getTransactionData() and look for the line ‘transactionId’ => $order->getIncrementId(), roughly line 74 above this line insert the line ‘event’ => ‘trackTransaction’,

Thats the magento side of things sorted now onto Google Tag Manager.

Login to Google Tag Manager create a new tag, maybe called it GA Conversion

Tag Type: Universal Analytics

Track Type: Transaction

Add a firing rule name it whatever you like mines Checkout Success, then add a condition of {{event}} equals trackTransaction

This then links trackTransaction from the array in the datalayer to Google Tag Manager, put a transaction through and wait half an hour as it takes a little bit of time to display in Google Analytics Ecommerce Tracking.

Magento Paypal express review remove terms and conditions

When you’ve placed an order in Magento using Paypal express checkout you are taken to /paypal/express/review/ if you’ve read my previous posts you will see my method of removing this step. If you remove the step as I suggested but have terms and conditions that you have to agree too, you will still be taken to that page , to avoid this go to:


Search for :

public function placeOrderAction()
try {
$requiredAgreements = Mage::helper(‘checkout’)->getRequiredAgreementIds();
if ($requiredAgreements) {
$postedAgreements = array_keys($this->getRequest()->getPost(‘agreement’, array()));
if (array_diff($requiredAgreements, $postedAgreements)) {
Mage::throwException(Mage::helper(‘paypal’)->__(‘Please agree to all the terms and conditions before placing the order.’));


Comment out the following lines with a simple // at the beginning :

//if (array_diff($requiredAgreements, $postedAgreements)) {
// Mage::throwException(Mage::helper(‘paypal’)->__(‘Please agree to all the terms and conditions before placing the order.’));
// }

Magento Matrix Rates and Recurring Profiles (nominal items)

I posted the following question on stackoverflow:
I’m using magento and I have matrix rates to handle the shipping, I’ve just setup a product with a recurring profile, magento’s knowledge base says this for recurring profiles “The list of available shipping methods during the shopping cart checkout is restricted to the fixed only (Fixed, Table Rates, and Free).” however I want to know if any one has been successful in making matrix rates work with recurring profiles?

My answer is now yes and its pretty simple!

This isn’t tested fully yet but I have managed to get it to work by simply adding

protected $_isFixed = true;

To the following

class Webshopapps_Matrixrate_Model_Carrier_Matrixrate
extends Mage_Shipping_Model_Carrier_Abstract
implements Mage_Shipping_Model_Carrier_Interface

In the file


Removing paypal/express/review step in Magento

If you use Paypal express in Magento it has a rather annoying /paypal/express/review page once you have confirmed everything in Paypal. Its quite simple to remove this page

Firstly go to:


Look for  $this->_redirect('*/*/review');

Replace with $this->_redirect('*/*/placeOrder');

Secondly go to:


Look for

public function getExpressCheckoutStartUrl($token)
return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'token' => $token,

Replace with

public function getExpressCheckoutStartUrl($token)
return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'useraction' => 'commit',
'token' => $token,

Finally still in /app/code/core/Mage/Paypal/Model/Config.php

Do the same as above and look for

public function getExpressCheckoutEditUrl($token)
return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'token' => $token,

Replace with

public function getExpressCheckoutEditUrl($token)
return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'useraction' => 'commit',
'token' => $token,

This method worked correctly for me in Magento 1.9 CE

Magento Upgrade 1.8 to 1.9 via connect

There seems to be a lot of discussions about surrounding upgrading Magento from 1.8 to 1.9 however there seems to be very few people commenting on upgrading using Magento Connect. I have never upgraded this way before but thought I’d give it a try, and in fact it was very easy. Obviously goes without saying that you need to backup both files and database just in case! Then simply go to Magento Connect > Check for upgrades > then choose the latest versions of all the modules to upgrade. During this time your store will go into maintenance mode. Flush your caches, test everything works and hopefully you will have a fully functioning version of Magento 1.9