Creating custom magento reports

Share
Posted on December 3rd, 2012 | Posted by admin

Creating custom magento reports

This post is going to be LONG. And not fun. To be honest, I’m not sure how some of this stuff works, but I do know that I have successfully created two different kinds of reports.

Some things to note:

  • You should never create reports off of a transactional table. Running the report could potentially create locks that would affect your customer facing website.
  • This blog post will not contain examples of “aggregation observers and tables”, but you should use them when creating reports. You run them through cron and an example observer can be found here: Mage_Sales_Model_Observer.

Let’s get started shall we? I will give examples of two different kinds of reports in this post. They will be called:

  • Simple – A report that has the thin/horizontal form for selecting “to”, “from” and “period”. (See Reports > Customers > New Accounts)
  • Complex – A report that has a seperatly defined filter block for filtering the report data. ( See Reports > Products > Best Sellers)

Simple Report

Magento :Images Not Showing In Front End

Share
Posted on December 2nd, 2012 | Posted by admin

It is a common issue in Magento. After uploading images from back end, the images are shown in back end, but are not displayed on the front end. To solve follow the below steps. Any one of them might solve the issue for you, or even you might need to apply all.

1. In back end go to System -> Cache Management. Click all check boxes. Choose ‘Refresh’ option from ‘All Cache’ drop down. Click ‘Save Cache Settings’. Once the page reloads select ‘Disable’ from drop down and again press ‘Save Cache Settings’.

2. On the same page you will find a button ‘Clear’ beside ‘Images Cache’. Click it.

3. Go to Catalog -> Manage Products. Click the specific product. Go to ‘Images’ tab. Beside the image there will be 3 radio buttons (Base Image, Small Image, Thumbnail). See if the required radio is selected or not. Also check if Exclude is checked or not. If checked uncheck it and save product.

How to fetch data from custom table in magento

Share
Posted on November 29th, 2012 | Posted by admin

Fetching data from custom table in magento is quite difficult because its data store in entity attribute value (EAV) model therefore most of the table structure are in EAV model. So joining one table with other tables is different from other database system. Here is a query example of sample table which helps you to use join, select, group, filter data from custom table .

Here are some examples of code which helps you to retrieve data from custom table using join, select.

1)
<?php
$collection = Mage::getModel('rewardpoints/points')-&gt;getCollection();
			$collection-&gt;addFieldToFilter('source','product');
			$collection-&gt;addFieldToFilter('recipient_email',Array('neq'=&gt;''));
			$expr = 'COUNT(points_id)';
			$collection-&gt;setOrder($expr,'DESC');
			$collection-&gt;setGroup('source_id');
			$collection-&gt;addProductData();
?>

2)
protected function _prepareCollection()
		{
			$read = Mage::getSingleton('core/resource')-&gt;getConnection('core_read');

			$firstname  = Mage::getResourceSingleton('customer/customer')
-&gt;getAttribute('firstname');
			$middlename = Mage::getResourceSingleton('customer/customer')
-&gt;getAttribute('middlename');
		    $lastname   = Mage::getResourceSingleton('customer/customer')
-&gt;getAttribute('lastname');
			$email      = Mage::getResourceSingleton('customer/customer')
-&gt;getAttribute('email');

Magento Installation pdo_mysql, mcrypt extensions error

Share
Posted on November 26th, 2012 | Posted by admin

Magento Installation pdo_mysql, mcrypt extensions error

Magento is becoming more and more popular and whilst installing Magento many clients come across the following message

PHP Extension “pdo_mysql” must be loaded
PHP Extension “mcrypt” must be loaded

To resolve the issue, firstly you would need to find out which php.ini file is used by your website. This can be achieved using phpinfo().

phpinfo() is commonly used to check configuration settings and for available predefined variables on a given system. If you don’t already have an info.php page in your hosting space. Please create a new text file and upload it to your hosting space. You will need to name the file info.php

Your new info.php page should have 1 line of code only. Please put the following code in your new file:

Code:

That’s all you need, now save the file to your hosting space, and view the php page in your browser.
Once you view info.php in your web browser, it will populate the page with all the PHP settings and values. It is a good resource to determine what the current settings are for your PHP installation.

Magento – HTML Minify Code Causing Some Javascript Not Working?

Share
Posted on November 25th, 2012 | Posted by admin

I have the below code to remove white space in a Magento site.

ob_start(“htmlcompress”);
function htmlcompress($buffer) {
$buffer = preg_replace(‘/…………….

and “giftmessage/inline.phtml” where toogle function disabled; also the “payment/form/cc.phtml” where radio button for payment options. Not all inline scripts got disabled though, for instance, anything start with “var” are working. How I can improve the compress script to prevent javascript from stop working?