Archive for the ‘Magento’ Category

New Website for Activo:

November 23rd, 2010
Comments Off

I have good news and bad news to tell you, well it is not really bad news, but just wanted to use that saying…

The bad news is that this website is has just become absolute. Meaning we will no longer publish anything new or introduce any new content on this website. The good news is that we already have a new website and the new website can be found at Notice that we got the domain name that we always wanted to have for Activo – Yeah!


For those of you who are interested, the new website was launched in late August of 2010. The domain was purchased back in November of 2009. The site currently already have twice the amount of traffic that this website has. The site also reflects a few changes in Activo:

  1. We moved our offices from Santa Clara to Los Angeles – and we love it down here. In fact LA is a great hub for techies and entrepreneurs, believe it or not.
  2. We now have a virtual team of developers, designers, and project managers. Yes – it was a decision we had to make back in the days before we moved and it turned out to work great. Our customers love it.
  3. We have decided to focus on Magento Development and Magento Extensions. I got to say, what a great decision that was!

So, check out the new website and our new blog. I (Ron Peled) will continue to post regularly about our daily grind and share with you as much as possible from what I am doing at any given time. Drop me a line if you have any suggestions or recommendations.

.NET Framework, AJAX, Content Management Systems, eCommerce, Ektron, Joomla, LAMP: Linux Apache MySQL PHP, Magento, Performance Optimization, PHP/MySQL, Project Management, Search Engine Optimization (SEO), Web Application Hosting, Web Design, Web Development, Web-based User Interfaces, ZenCart

How to Detect if the Page is Secure in a Magento Template?

October 22nd, 2009
Comments Off

When you are designing a Magento template it is easy to overlook a simple fact: most links should not be hard-coded and you should always use the methods that are available for you like getSkinUrl() and getJsUrl(). In addition to pointing to the right root folder, these methods also point to the secure or unsecure URLs, ‘https’ and ‘http’ respectively. However, how can you detect if a URL needs to be secured or not?


In a recent Magento project, I needed to do exactly that: find out if we are in secure or in a non secure page and point to the right jQuery file on Google CDN’s. Here is the code:

<?php if(Mage::app()->getStore()->isCurrentlySecure()): ?>
<script src="" type="text/javascript"></script> 
<?php else: ?>
<script src="" type="text/javascript"></script> 
<?php endif;  ?>

The key method here is the Mage::app()->getStore()->isCurrentlySecure().

Reblog this post [with Zemanta]

Magento , ,

Magento’s massAction for Custom Plugins

October 8th, 2009
Comments Off

Ever wanted to allow your users to make mass action on your Magento Custom Plugin records? The good news is that it is built in to the Magento Admin Panel and is available at the community edition. The bad news is that there is absolutely no documentation on how to use it. Here are the 3 steps you will need to take in order to develop this feature in your custom plugin:


1. Prepare a Grid Container and Grid in your backend:
For this you will need a collection of records, a controller, and the basic blocks of a grid admin page. I will not cover this in this post, but you can find more about setting it up nicely on Tips for Twits Magento Blog, the article is called Howto: Repackageable custom extension development in Magento.

2. Add the _prepareMassaction() method inside the Grid class:
Add the following code inside your module class that extends Mage_Adminhtml_Block_Widget_Grid:

protected function _prepareMassaction()

 $this->getMassactionBlock()->addItem('add', array(
 'label'    => Mage::helper('rma')->__('Add Products to RMA List'),
 'url'      => $this->getUrl('*/*/massAdd'),

 return $this;

A few things to notice:

2.1. ‘entity_id’ is the database column that serves as the unique identifier throughout your data structure, including: db table, single product magento model, and the collection.
2.2. setFormFieldName(‘product’) – the text ‘product’ is flexible but you will need it in the next step, so remember it.
2.3. The routing string ‘*/*/massAdd’ will triger a method called massAddAction() in your controller.

3. Prepare the actual action to be taken in your controller
Here is the code that needs to be added, notes are below:

public function massAddAction()
 $productIds = $this->getRequest()->getParam('product');
 if(!is_array($productIds)) {
 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('rma')->__('Please select product(s)'));
 } else {
 try {
 $product = Mage::getModel('catalog/product');

 foreach ($productIds as $productId) 
 $rmaProduct = Mage::getModel('rma/product');
 'Total of %d product(s) were successfully added to the RMA product list', count($productIds)
 } catch (Exception $e) {




3.1. The method name is routed from the previously provided $this->getUrl(‘*/*/massAdd’) method.
3.2. Yes, the variable $productIds contains a simple array of entity_id numbers. This is not a collection by any means, so you should treat it this way.
3.3. Inside the main foreach loop, you can pretty much do whatever action you wanted.

In conclusion, with about 20 lines of code and updates to two files we are able to leverage a powerful built in feature provided by Magento which allows for mass actions on our records. Obviously, this little excerpt is not for the beginners out there. However, I hope this will make some developers’ lives a bit easier.

Let me know how what other advanced Magento features you use the most.

Magento , ,

Coming Book Review for Magento: Beginner’s Guide

October 1st, 2009

Magento-for-Beginners-GuideI’ve recently been approach by a UK publisher, Packt Publishing, to review a new books about Magento. The book is called Magento: Beginner’s Guide and covers many aspects of the Magento eCommerce platform. In fact, it almost seem like an intermediate or even advanced from a merchant’s point of view. Here are a few pros and cons for this book which I drafted from a quick 10 minutes glance:


  • From the table of content, the book seem to be comprehensive and covers many parts of the Magento eCommerce.
  • The book has a duo setup of Author(William Rice) + Technical Reviewer(Jose Argudo) – which is promising.
  • Installation chapter includes FTP instructions and folder/file permissions instructions which is more than I have seen in similar books.


  • The book claims to target everyone. Realistically, this book seem to target smaller merchants who will be installing, setting up, and running the store themselves.
  • The book refers to a bit outdated version of Magento: 1.2.x.x. Not a big issue since Magento’s main features have not changed much.
  • Seem to be a bit technical for the average smaller merchants. Still remains to be seen how technical.

If you have any thoughts about this book or if you read it and have something to say about it, let me know.


Magento’s Order Management Workflow: Comprehensive but Unrealistic #2

September 29th, 2009

Yes, I finished the goEmerchant payment plugin for Magento and figured out how to use and modify Magento’s Order Management Workflow. It did require a lot of reverse engineering and a bit of tweaking of the button labels to improve the admin’s understanding on what each operation actually does.

Magento's Order Management Workflow is like a plumbing job, maybe not so bad.

Pre-Authorize transaction on Checkout:
So, the first thing we want to do is pre-authorize transactions when a user places an online order and checks out from Magento. That is relatively easy and mostly built in. Nothing needed to change from a workflow point of view. The only thing we had to realize is that there are two values that stay with the payment which is associated with the Order and we can use for the goEmerchant reference_number. Those are: ‘cc_trans_id’ and ‘last_trans_id’ – I chose to use ‘cc_trans_id’ just because it made more sense.

Cenceling & Voiding an Order:
In Magento you can only void invoices. However, if you create an invoice you in effect will triger the captur() method of the payment. Now, goEmerchant allows you to void only unsettled transactions – so we had to handle the voiding before we create an invoice. Luckily Magento has the cancel() method that is called when an order is canceled. So, we wired the void operation to the cancel() method and relabeled the button from ‘Cancel’ to ‘Cancel & Void’ – to explain what it actually does. We also turned off voiding, since there is not much sense in voiding an already created/settled invoice.

Settling a Transaction (Capture Funds):
goEmerchant needs the eCommerce application to send a ‘settle’ request when the order was processed, shipped, and invoiced. This request than places the transaction in the settled queue and will be processed usually at 2am. This was relatively easy and no modifications to the workflow needed here. All we needed to do is perform the ‘settle’ request in the capture() method of the payment. Note: since our module still allows Authorization & Capture setups, we had to handle the special cases here. But overall no problem.

Refund or Creditmemos:
Magento has this option to create new credit memos, these serve as what we call it as refunds. Luckily, here Magento’s Order Management Workflow works finde and allows you to process a credit memo and ‘Refund Online’. It is actualy labeled ‘Refund’ and the other option is to ‘Refund Offline’. So, in our plugin we are simply wiring the refund request in the refund() method of the payment. Note: Magento also allows a refund of the entire order which is not triggering anything. So, we will need to be cautious to explain to our merchants that they will need to refund already created invoices.

Magento’s Order Workflow is definitely rich in features and allows great level of flexibility for the merchants. However, some of it would not make sense and seems like overly complex for something that should be configurable but simple. We were able to get our plugin working the way we needed it to by a combination of using the existing functionality and relabeling some buttons. We will also need to caution our merchants from certain actions or make the decision to remove these options altogether.

If you are interested in our goEmerchant payment module for Magento, email us at or call at (888) 897-7775.

Magento ,

Magento’s Order Management Workflow: Comprehensive but Unrealistic

September 25th, 2009

Here I am, knee deep finalizing a Magento goEmerchant payment module. When done, the module will integrate a Magento store with the goEmerchant XML API which will allow seamless pre-authorizations, captures (on invoicing), refunds, and voids.  All will be handled by the Magento admin panel at the order management pages. Well, I have just discovered how Magento handles things and it is slightly different then what we need it to be. In fact, it is different than what any payment gateway will require. Let me explain:


Assuming that the Magento is configured to Authorize only on checkout, once an order is processed, the payment info will be sent to the gateway and a Credit Card pre-authorization will occur. Resulting in a reference_number which is stored somewhere in the database. In the back-end, an admin will then review all the open orders, or orders under the ‘processing’ status and will create invoices accordingly. When the invoice is created there is an option to Capture the funds at that point. Great! this is almost what needs to happen, but workable. In essence, pre-authorized transactions need to be ‘Settled’ not ‘Captured’ according to goEmerchant’s logic. Not a problem.

What is problematic and will require serious re-plumbing of the Magento logic is the fact that only captured invoices can be voided. Well, this defeats the purpose because that is why we pre-authenticate. In short, according to Magento, a pre-authenticated order can issue an invoice which will then capture the funds and only then one can void the captured, pre-authorized transaction. This is a problem in the logic! What needs to happen, according to goEmerchant, is the ability to void a pre-authorized order without the need to issue an invoice and capture the funds.

I’ll keep you posted on this… to be continued.


Howto change the Base URL in Magento via command line

August 7th, 2009

A quick howto that complements chandansweb’s article on how to change the Base URL using phpMyAdmin. On production servers I do not install phpMyAdmin and therefore I need to use command line. Here is how in 3 steps:

Step 1: Login to mysql (command line) and update two records:
Note that the values in square brackets need to be filled with your specific values.

update [prefix]core_config_data set value="http://[domain]/[rootfolder/]" where path='web/unsecure/base_url';
update [prefix]core_config_data set value="http://[domain]/[rootfolder/]" where path='web/secure/base_url';

Step 2: Clear cache by removing entries in the /var/cache/* folder:
Careful with this one, make sure you are pointing to the right folder.

rm -rf /var/www/[path to html folder]/var/cache/*

Step 3: Force Magento to clear its database cache by running this php file:
Note that I recommend that you copy and paste this code in a file at your Magento root folder. Then point your browser to this file, it will trigger the clearing of various cache objects in Magento.

ob_implicit_flush(true); //Saves having to flush manually
set_time_limit(0); //Set time limit to unlimited, though we shouldnt need to


// clean overall cache

// clear 'refresh_catalog_rewrites':
echo 'Catalog Rewrites was refreshed succesfuly<br>';

//  clear 'clear_images_cache':
echo 'Image cache was cleared succesfuly<br>';

//  clear 'refresh_layered_navigation':
echo 'Layered Navigation Indices was refreshed succesfuly<br>';

That should do it, you should now be able to point to your production store and it will pull the right URLs. It worked for me after various attempts of other howto’s. The above steps are the ones that worked for me.

Magento , ,

Is Magento for eCommerce Scalable?

August 4th, 2009
Comments Off

My recent experience with Magento brings a doubt: is Magento Scalable? I am finalizing a plugin that will allow catalog synchronization with a POS system. Some stores have over 10,000 products, skus to be accurate. I have extended the core classes to accommodate for the product import with certain attributes and was shocked to discover that for each new product saved, or in code terms, each $product->save() it was hammering the DB with approximately 1,000 queries. That also meant that importing 1,000 products took approximately 3-5 minutes on a powerful server which included 15K SCSI hard drives.


Writing directly to the database is not an option because it will potentially introduce a problem with any upgrade efforts and in general is not recommended. There is a limit to how much hardware is being thrown at Magento in order to cover for any performance imperfections. Additionally, almost any interaction with the Magento support team results in lists of mysql configuration best practices which are already in place. Magento: you can run but you cannot hide! Perhaps you cannot run either.

The bottom line is that I am positive that there is a solution, and I am 100% convinced that the Magento developers are working on a solution as I write this blog. It is only in the meantime that it is painful to see all these great sites serving ‘gummy’ pages and developers asking how to add the ‘Please wait while loading’ AJAX loader to the front end of the store…


Magento: Hard but not Impossible

August 4th, 2009
Comments Off

magento_hard_but_not_impossibleIn the last few weeks I have been hard at work on a Magento plugin that extends the eCommerce app to become a front end of a POS (point of sale) system. With over 6,000 files Magento can certainly be intimidating at first, but as you get familiar with its architecture you find it less and less intimidating. One main design feature makes it easy to find a class by its class names.

For example, the class Mage_Catalog_Model_Product will be located in the /app/code/core/Mage/Catalog/Model folder and the file name is Product.php. If you ever need to instantiate the class, use Mage::getModel(‘catalog/product’).

Another useful tip about the architecture is that most everything is handled in the various session objects and every operation is basically an event that occurs which then calls a certain method within a particular class. Some of these events are dispatched and can be used by Magento’s event/observer architecture but most are not and therefore one needs to override the class instead.

I know this is very vague but will make sense if you are knee deep inside the magento code.

eCommerce, Magento, Web Development

The Case for ZenCart: Supporting the Long Tail of eCommerce

June 18th, 2009

While Zen-Cart is one of the best open source ecommerce platforms it has plenty of deficiencies, however I recently understood that it will always be able to keep its niche and therefore always have a market.  Of-course this will remain the case as long as its leaders remain true to its spirit.


Zen-Cart is an unwilling offspring of the popular osCommerce. Like all offsprings, it is an improved version of its predecessor with better templating system, class oriented design, and notification systems but still maintains its characteristics of spaghetti code and somewhat convoluted and non-flexible checkout process.

Zen-Cart’s strengths are its simplicity which gives many non-programmers the opportunity to tweak and add (or remove) features to their likings with no major effort. This means that implementing a Zen-Cart ecommerce website is usually inexpensive and fast. Another great benefit of the system’s simplicity is speed. Zen-Cart is many times lighter than many other ecommerce systems even without complex caching technologies. Together, these benefits support a specific market: the market of light ecommerce. I am talking about online shops with 1 to 100 daily transactions or even less. It can obviously support more than that but the simplicity and the light weight features will attract the small business which is budget oriented.

The light ecommerce market while being small in terms of overall sales figures is relatively large and will get larger and larger with time. This is also known as the long tail of any market, in our case it is the long tail of the ecommerce market. This means that the numbers of installations will most likely be large and not insignificant. It also means that it is a valid market and will not vanish overnight with any other solution such as Magento who now charges a hefty amount for licensing its Enterprise version.

Before you rush to declare this light and feature packed ecommerce platform the kind of the long tail ecommerce market, don’t underestimate the challenges that it is facing. With over a year and a half of no significant updates its market share is shrinking fast. The default template and the admin panel need some serious reworkings to get up to par in UI and design with other open source challengers and a major cleanup and reorganization of the backend configurations is way overdue. While it supports XHTML and validates correctly, the default template needs to be reworked without the tables.

In any case, Zen-Cart still serves its purpose as a free and light open source ecommerce platform. And here at Activo we have recently developed a Recurring Orders payment module that comply with PCI requirements and integrates well into the ARB module of I’ll soon post links to an initial free version, a commercially licensed version should be available in about a month or so.

What do you think of ZenCart? here to stay or yet another open source project that will be lost in oblivion? somewhere in the middle perhaps?

eCommerce, Magento, Web Development, ZenCart , , ,