My Cart
Filters

Top Ten Problems Every Magento Store Will Inevitably Face. Part 2

To developers, savvy merchants and support teams...

I have already reviewed the first 5 problems from the Top Ten Magento Store Problems List. If you were busy or occasionally missed them last week, it’s a good time to open the Part 1 right now: chances are high you were stuck with these issues before, so you can compare our recommendations with your experience. When nothing similar happened to you, don't take trouble-free situation for granted. The best way to deal with potential difficulties is to be prepared for them.

As a head of support team in aheadWorks I strongly advise you to study below-mentioned cases and get equipped with knowledge which will never be wasted. When one of these challenges arises, you will be done with it in a moment.

Top 10 M problems


Q6: Extensions that use cron are working incorrectly.
A6: Code I present shows one of many available protection methods against the restart of a running task.  

[php] const L_CACHE = 'aw_hdu_lock';
const L_TIMEOUT = 300;

public function runJobs() {
if (self::checkLock()) {
$this->processJobs();
Mage::app()->removeCache(self::L_CACHE);
}
}

public static function checkLock() {
$_lastExecutionTime = Mage::app()->loadCache(self::L_CACHE);
if (self::L_TIMEOUT > (time() - $_lastExecutionTime)) {
return false;
}
Mage::app()->saveCache(time(),self::L_CACHE,array(),self::L_TIMEOUT);
return true;
}
[/php]


Q7: Valid code returns errors instead of working flawlessly.
A7: Here I detect the problem with methods of the latest php version, while on the client’s website the earlier php version is installed. Below I point out the code with late static binding (Kung Fu from the 5.3 php version, that does not work on the 5.2).

[php] abstract class AWAS_Model_Indexer_Abstract
{
public function getIndexTableModel() {
return new AWAS_Model_Zend_Db_Table(array(
Zend_Db_Table_Abstract::PRIMARY => static::PRIMARY
));
}
}
class AWAS_Model_Indexer_Catalog extends AWAS_Model_Indexer_Abstract
{
const PRIMARY = 'entity_id';

protected function _fillData() {
$table = $this->getIndexTableModel();
}
}
[/php]

The next code is the same one, rewritten the way to use methods familiar to old php versions.

[php] abstract class AWAS_Model_Indexer_Abstract
{
abstract protected function _getPrimary();
public function getIndexTableModel() {
return new AWAS_Model_Zend_Db_Table(array(
Zend_Db_Table_Abstract::PRIMARY => $this->_getPrimary()
));
}
}
class AWAS_Model_Indexer_Catalog extends AWAS_Model_Indexer_Abstract
{
const PRIMARY = 'entity_id';
protected function _fillData() {
$table = $this->getIndexTableModel();
}
protected function _getPrimary(){
return self::PRIMARY;
}
}
[/php]

The bottom line here: before doing customization, check technology versions your store is based on. Only after this being done, start writing code that will work with all current versions.

 

Q8: You have installed the extension, but cannot log in to the admin panel.
A8: During extension installation compilation was enabled. The picture shows what you can do, using a standard Magento arsenal.

code-19

 

Q9: You have customized the store, added new features, changed the template and theme styles. Few weeks later you saw that all changes stopped working.  
A9: This is the example of how custom-pack should look like, where each file with changes is duplicated (.MODIFIED). Its original version is also saved as backup (.ORIGINAL).

code-21

Backups allow tracking changes at any given time, i.e. what was made. Duplicates contain all the work in case you update the extension and unintentionally remove changes.

 

Q10: For developers only. A customer sets the task for you, but refuses to give the required accesses.
A10: Image below demonstrates the list of folders, to which you need accesses in most cases. I recommend to discuss the necessity of accesses with a customer way before you proceed with the task. Define special folders to be revealed instead of requiring full access to everything.

code-23


Forewarned is forearmed. I hope that knowledge of these ten problems and their solutions will help you in operating your Magento store. I am absolutely sure you will find or have already discovered more elegant ways to deal with these cases. If so, do us a favor and share your strike findings in comments!