Magento: Some product view page become blank

When take the view of the product view in Magento, some product pages shows blank page but other product pages are working fine. This blog try to explore some solution for this


When one get issues like such as the blank page for some of the product view page, check the each of functions used in the product view page. When checking the function, there is a possibility that one can find the PHP functions of the mbstring extension like mb_detect_encoding().

Then check the PHP environment through the phpinfo(). From the displayed list of the PHP extension, probably one couldn’t see the mbstring PHP extension.

Good idea to check with server support team for installing and enabling the mbstring extension. After it is enabled, the product view page of all products should work fine.

Some of the Magento extensions used the mbstring php function. For eg: Technooze magento module has one feature like display Meta Description Tag on Product View Page. In this, one of the mbstring PHP function named mb_detect_encoding() is used.

Posted in Magento Developer Notes | Leave a comment

Drupal: Customizing Apachesolr Autocomplete feature for content-type wise grouping of keyword suggestions.

Issue: In Drupal, can we group ApacheSolr search autocomplete suggestions bundle wise?
For example, if we have three bundle types, those are article, product and company. When we type a keyword in the search box, it should give us the options to search in keyword in article, keyword in product and keyword in company. Also, we need a separate suggestion count for each bundle. There is a dropdown box for listing bundle type options on the right side of the searchbox. We used Custom Search module for displaying this dropdownbox as an advanced search criteria.

We can achieve this option by overriding Apachesolr Autocomplete module by customizing the ApacheSolr Search Query.
Please see the modified ‘apachesolr_autocomplete_suggest’ function from apachesolr_autocomplete.module.

function apachesolr_autocomplete_suggest($keys, $params, $orig_keys, $suggestions_to_return = 5) {

$matches = array();
$suggestions = array();
$keys = trim($keys);

// We need the keys array to make sure we don't suggest words that are already
// in the search terms.

$keys_array = explode(' ', $keys);
$keys_array = array_filter($keys_array);

// Query Solr for $keys so that suggestions will always return results.
$query = apachesolr_drupal_query($keys);

// This hook allows modules to modify the query and params objects.

drupal_alter('apachesolr_query', $query);
if (!$query) {
return array();
foreach ($params as $param => $paramValue) {
$query->addParam($param, $paramValue);

// Query Solr

$response = $query->search($keys);

// Loop through requested fields and get suggestions.

foreach ($params['facet.field'] as $field) {
foreach ($response->facet_counts->facet_fields->{$field} as $terms => $count) {
$terms = preg_replace('/[_-]+/', ' ', $terms);
foreach (explode(' ', $terms)  as $term) {
if ($term = trim(preg_replace('/['. PREG_CLASS_UNICODE_WORD_BOUNDARY .']+/u', '', $term))) {

if (isset($matches[$term])) {
$matches[$term] += $count;
else {
$matches[$term] = $count;
if (sizeof($matches) > 0) {

// Eliminate suggestions that are stopwords or are already in the query.
$matches_clone = $matches;
$stopwords = apachesolr_autocomplete_get_stopwords();
foreach ($matches_clone as $term => $count) {
if ((strlen($term) > 3) && !in_array($term, $stopwords) && !array_search($term, $keys_array)) {
// Longer strings get higher ratings.
#$matches_clone[$term] += strlen($term);
else {

// Don't suggest terms that are too frequent (in >90% of results).
$max_occurence =  $response->response->numFound * 0.90;
foreach ($matches_clone as $match => $count) {
if ($count > $max_occurence) {
// The $count in this array is actually a score. We want the highest ones first.

// Shorten the array to the right ones.
$matches_clone = array_slice($matches_clone, 0, $suggestions_to_return, TRUE);
// Add current search as suggestion if results > 0
if ($response->response->numFound > 0 && $keys != '') {
// Add * to array element key to force into a string, else PHP will
// renumber keys that look like numbers on the returned array.
$suggestions['*' . $keys] = array('theme' => 'apachesolr_autocomplete_highlight', 'keys' => $keys, 'suggestion' => $keys, 'count' => $response->response->numFound);

// Build suggestions using returned facets
foreach ($matches_clone as $match => $count) {
if ($keys != $match) {
$suggestion = trim($keys . ' ' . $match);

// On cases where there are more than 3 keywords, omit displaying
//  the count because of the mm settings in solrconfig.xml

if (substr_count($suggestion, ' ') >= 2) {
$count = 0;
if ($suggestion != '') {

// Add * to array element key to force into a string, else PHP will
// renumber keys that look like numbers on the returned array.

$suggestions['*' . $suggestion] = array('theme' => 'apachesolr_autocomplete_highlight', 'keys' => $orig_keys, 'suggestion' => $suggestion, 'count' => $count);
/* Here our custom code starts */
$suggkey = $suggestion;

// Returns the basic set of parameters for the Solr query.
$suggparams = apachesolr_autocomplete_basic_params(0.2);
$suggparams['facet.prefix'] = $suggkey;
$suggquery = apachesolr_drupal_query($suggkey);
drupal_alter('apachesolr_query', $suggquery);
$suggparam = array();
foreach ($suggparams as $suggparam => $suggparamValue) {
$suggquery->addParam($suggparam, $suggparamValue);

// Specify bundle types as facet query parameters for determining counts.
$suggquery->addParam('facet.query', 'bundle:article);
$suggquery->addParam('facet.query', 'bundle:product);
$suggquery->addParam('facet.query', 'bundle:company);

// Provides a content search implementation for node content for use with the Apache Solr search application.
$suggresponse = $suggquery->search($suggkey);

// Retrieve the unique count for each bundle type.
$articlecount = $suggresponse->facet_counts->facet_queries->{'bundle:article'};
$productcount = $suggresponse->facet_counts->facet_queries->{'bundle:product'};
$companycount = $suggresponse->facet_counts->facet_queries->{'bundle:company’};

// Add into suggestions array
$suggestions['*' . $suggestion"] = theme('apachesolr_autocomplete_highlight', array('keys' => $orig_keys, 'suggestion' => $suggestion, 'count' => $articlecount, 'bundle_suggest' => 'article'));
$suggestions['*' . $suggestion"] = theme('apachesolr_autocomplete_highlight', array('keys' => $orig_keys, 'suggestion' => $suggestion, 'count' => $productcount, 'bundle_suggest' => 'product'));
$suggestions['*' . $suggestion"] = theme('apachesolr_autocomplete_highlight', array('keys' => $orig_keys, 'suggestion' => $suggestion, 'count' => $companycount, 'bundle_suggest' => 'company’));

/* Here custom code ends*/
return array(
'suggestions' => $suggestions,
'response' => &$response

Posted in Drupal Developer Notes | Leave a comment

Responsive layouts Web design and JQuery

One of the popular contemporary topic among web design and development is responsive layouts web design. Responsive layouts allows the web designers to design attractive websites which are device friendly and thereby increasing the number of users or audience of the website. Users can view the same website through wide range of devices such as PCs, Smart phones and tablets. Responsive web design technology is an art which gives convenience to users and gives better aesthetics to websites on different devices. Responsive design offer many advantages over non responsive layouts. Some of the major advantages are:

Adaptive to Multi-devices

As the numbers of mobile devices are fast increasing and probably is going to exceed the human population, the usage of mobile devices is never going to decline. Users started accessing websites through different devices and they expect the same user experience and functionality. They can be very easily achieved by using Responsive layouts or with the help of responsive web design. Responsive layouts are multi device adaptive i.e. responsive layouts adapt to screen of the device such as iphone or tablet and website can be easily accessed and browsed with it.

Easy Modification and maintenance

With the advent of responsive web design, using different websites with different urls for mobile devices and PC is becoming outdated. Responsive layouts are used so that there is no need for keeping a sub domain for mobile devices making it easy for maintenance and modification.

Better Conversion Rates

With the type and number of devices used for accessing the website increased, with the marketability of website is increased, business or sales of goods and services of the website will be increased. There is more chance of converting the mere visitors of website to customers. There by it can boost the sales

Better User experience

Multi-device adaptive or responsive design will enhance the user experience. When the user is accessing the website through different device, with a properly designed responsive layout, there will be no chance of any design issues which will affect the usability of the website and the user can have good overall experience irrespective of the device with which is browsed. Responsive wed design also responds with the change in browser window width, hence it is one of the main reasons for naming it so.

Improved Website performance

With all these advantages of responsive web design, the whole website performance will be increased which will aid to the goal and functioning of the website.

One of the major disadvantages of the responsive web design is that it might make the page load slower. Though it enhances SEO and Google supports it, the site ranking won’t be negatively affected without responsive web design.

Converting a fixed width, non-adaptive site to a multi-device adaptive or responsive site is not an easy task. This process might take good amount of time required to development the website. It can vary from from 40% to 100% of the time taken to develop the web site. This process of converting fixed with to responsive can be done comparatively easier with the help of JQuery and its plugins. In the web, there are a lot of JQuery plugins which help us to optimize the website and aid in converting a fixed width site to a responsive website. With the help of JQuery plug-ins flexibilities of responsive web design can be achieved.

The basic logic behind the jQuery plug-in are checking for the dimensions of the document or window and making necessary changes to style of elements such as altering the width, hiding and showing elements etc.We may need to change the size of images in pages or image slider or even change the size of fonts used in the website.
An example for developing a simple and basic jQuery plug-in that adds a responsive feature to website is described below:

Open a new file in editor and type the following:

(function($) {
$.fn.beflexible = function(){
return this.each(function(){
var origHeight=697;
var currHeight=$(window).height();
var em=Math.round(7*(currHeight/origHeight));
var emstring=em+"em";

Save it as “jquery.fontsize.js”.Save it in the same location where .html file is residing.

Add the following <script type="text/javascript" src="jquery.fontresize.js"></script>in the <head></head> tags.

Also add the following in the head of document:

<script type="text/javascript">

Add the following inside <body></body> tags

<div id="yourid" class="yourstyle">Hello,how are you?</div>

Save the document. Open the page in browser and Resize the window and see the changes. That’s it!

Thank you for reading and please share your valuable comments.

Posted in General | Leave a comment

Magento Free Shipping Promotion Rule is not working with some 3rdparty shipping modules

Magento’s Free Shipping Promotion Rule is not working with some 3RDparty shipping modules.


This issue can be resolved by adding some codes to the extension. For example, in Fontis Australia, the below condition was missing.

if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
$shippingPrice = '0.00';

Adding this code in the Shipping carrier extension’s model file, it will support the Promotion rule set for free shipping.

Posted in Drupal Developer Notes, Magento Developer Notes | Leave a comment

Error message from 3rd party Ebizmart’s MagemonkeyMailchimpmodule in magento

Installation ofthe 3rdparty magemonkeymailchimp module in magento, results in an error message in backend tab “Newsletter->Mailchimp->Ecommerce 360 Orders ->Ecommerce360 API Orders”.

The error message can be;

  • Fatal Error: Unsupported operand types in Block/Adminhtml/Ecommerceapi/Grid.php on line 34
  • OR

  • Sometimes a blank page without any error message.


  • Go to app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/Ecommerceapi/Grid.php.
  • On line number 34, comment the below line and save. $orders += $result['data'];
  • Then the function will be like as:protected function _prepareCollection()
    $orders = array();
    foreach(Mage::app()->getStores() as $storeId => $store){
    $api = Mage::getModel('monkey/api', array('store' => $storeId));
    $result = $api->ecommOrders(0, 500);
    // $orders += $result['data'];

    $collection = Mage::getModel('monkey/custom_collection', array($orders));
    return parent::_prepareCollection();

  • Then go to backend “Newsletter->Mailchimp->Ecommerce 360 Orders ->Ecommerce360 API Orders” and test. You can see the Ecommerce360 API Orders grid there.
Posted in Magento Developer Notes | Leave a comment

Solve the Delay in Mouse Over Effect for button

When using mouse over we use two images for the mose over effect for writing css. We observed a delay

Images used are given below

Normal state:-

Over state:-

See below for normal sprite methos

shop-now-btn {
background: url("../images/btn-shopnow.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
float: left;
height: 31px;
width: 129px;
shop-now-btn:hover {
background: url("../images/btn-shopnow-over.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);}

We changed the pattern of giving the class. Button are loading in one image is one of the solution to solve the issue. And class over effect is given like sprite method.


shop-now-btn {
background: url("../images/btn-shopnow.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
float: left;
height: 31px;
width: 129px;
shop-now-btn:hover {
background-position: 0 -33px;}

Thus by giving the position you can solve the delay issue.

Posted in Designer | Leave a comment

Receives a wrong output when saving the date of birth as 01.01.1970 during the customer registration.

Receives a wrong output n magento when saving the date of birth as 01.01.1970 during the customer registration OR updating the customer information.


  • Copy the Dob.php file in app\code\core\Mage\Customer\Block\Widget to corresponding local path.
  • Edit the function setDate($date)
    And add the below code:

if(strtotime($date) == "0"){
Then the function will be:
public function setDate($date)
//01.01.1970 – DOB issue -start
if(strtotime($date) == "0"){
//01.01.1970 – DOB issue -end
$this->setTime($date ? strtotime($date) : false);
$this->setData('date', $date);
return $this;

Posted in Magento Developer Notes | Leave a comment

Adding new export filter for products in Dataflow – profiles in Magento version 1.9

At first, we need to find where the export filters are located. Going through Magento core we can understand that export filters are stored in the form of array inside load () in:


Look for $attrFilterArray in load(), in that we can see:

$attrFilterArray = array();
$attrFilterArray ['name'] = 'like';
$attrFilterArray ['sku'] = 'startsWith';
$attrFilterArray ['type'] = 'eq';
$attrFilterArray ['attribute_set'] = 'eq';
$attrFilterArray ['visibility'] = 'eq';
$attrFilterArray ['status'] = 'eq';
$attrFilterArray ['price'] = 'fromTo';
$attrFilterArray ['qty'] = 'fromTo';
$attrFilterArray ['store_id'] = 'eq';

Suppose that we need to add a new export filter, let it be country of manufacture, an attribute of product, what we need to do is simple add that attribute just as shown below.

$attrFilterArray = array();
$attrFilterArray ['name'] = 'like';
$attrFilterArray ['country_of_manufacture'] = 'like';
$attrFilterArray ['sku'] = 'startsWith';
$attrFilterArray ['type'] = 'eq';
$attrFilterArray ['attribute_set'] = 'eq';
$attrFilterArray ['visibility'] = 'eq';
$attrFilterArray ['status'] = 'eq';
$attrFilterArray ['price'] = 'fromTo';
$attrFilterArray ['qty'] = 'fromTo';
$attrFilterArray ['store_id'] = 'eq';

The syntax for adding is:

$attrFilterArray ['attributecode'].

Important: we should not edit any core files or templates; this example is demonstrated by editing the core files/templates. We need to override the admin module.

Now, half of the work is done. Next we need to edit the phtml file. For that go to:


And open wizard.phtml file. Add the following code inside

<div class="profile_entity_type_product">
<span class="field-row">
<label for="product_filter_country_of_manufacture"><?php echo $this->__("Country of manufacture:") ?></label>
<input id="product_filter_country_of_manufacture" name="gui_data[product][filter][country_of_manufacture]" value="<?php echo $this->getValue('gui_data/product/filter/country_of_manufacture') ?>"/>

Now check the output and it will work perfectly…

Foradding a category filter, the process is comparatively more complex. There will be a change in logic of load() in Adapter.php. For that, a admin module must be created and Adapter.php must be overrided in such a way that it incorporates or uses the category resource model :
Mage::getResourceModel('catalog/category_collection')Thank you for reading and please share your valuable comments…

Posted in Magento Developer Notes | Leave a comment

Optimizing the ‘LIKE’ Search type in Magento version 1.9

Before going to optimize, please make sure that ‘Search Type’ is ‘Like’. It can be determined taking a look at:

System ->Configuration ->Catalog ->Search Type

Important: If we want to see any changes in frontend search results please make sure the search data is re-indexed.

Open the file:


Inside the prepareResult( ), see the code from line 343. The logic which we are going to change is in that particular line. Take a look at that part:

$like[ ] = $helper->getCILike('s.data_index', $word, array('position' => 'any'));

Here we can notice the parameter array(‘position’=>’any’).This means that Magento default search will search the word in such a way that the particular position of word will be anywhere .In SQL terms, we can say it will be like: %searchterm%

We can change that to ‘start’ or ‘end’ as defined in the class:

switch ($options['position']) {
case 'any':
$value = '%' . $value . '%';
case 'start':
$value = $value . '%';
case 'end':
$value = '%' . $value;

It is self explanatory and in SQL terms the ‘start’ and ‘end’ can be defined as searchterm% and %serachterm respectively.

In Fulltext.php, we can optimize the search further in such a way that AND logic can be used. See the code below:

if ($like) {
$likeCond = '(' . join(' OR ', $like) . ')';
It can be changed to:
if ($like) {
$likeCond = '(' . join(' AND ', $like) . ')';

So that the magento will search for items containing exactly all the terms.

Thank you for reading… Please share your valuable comments

Posted in Magento Developer Notes | Leave a comment

Select Box Issue in Updated Firefox



First we need to surround our select box element with a div container:

<option>Here is the first option</option>
<option>The second option</option>

Next we need to add CSS to make sure that the elements of the select box are styled a certain way:

.outer-select select {
background: transparent;
width: 268px;
padding: 5px;
font-size: 16px;
line-height: 1;
border: 0;
border-radius: 0;
height: 34px;
-webkit-appearance: none;

We need to make sure that our select box actually spans wider than the surrounding div container so that the default drop down arrow disappears.

Our div container needs to be styled like so in order for the new arrow to appear where we want it to:

.outer-select {
width: 240px;
height: 34px;
overflow: hidden;
background: url(new_arrow.png) no-repeat right #ddd;
border: 1px solid #ccc;

Posted in Designer | Leave a comment