Engine23

Magento Ecommerce Strategy, Design & Development

Magento Category not working and showing 404

If your not getting your Category pages to show up its probably because you have not set your Store Root Category.

System => Manage Stores => Select your store to edit and then set it there.

I wasted 4 hours today wondering why my categories were not showing up.

Disable Magento block caching for top navigation

Here is the scenario, I was using the topMenu for my main navigation.  I had some custom things being displayed in the UL that was not a catalog/category.  It was hard coded into my version of page/html/topmenu.phtml

$module = Mage::app()->getRequest()->getModuleName();
// Mage_Page_Block_Template_Links

$block = Mage::getBlockSingleton('page/template_links');
$layout = $block->getLayout();
$links = $layout->getBlock('top.links');
$header = Mage::getBlockSingleton('page/html_header');
?>

<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">

Read more

Magento - How to Remove Add to Compare

First step create the module declaration:

file: app/etc/modules/Russellalbin_Catalog.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Russellalbin_Catalog>
            <active>true</active>
            <codePool>local</codePool>
        </Russellalbin_Catalog>
    </modules>
</config>

Read more

Magento Abstract Class

If your trying to do a typical "Rewrite" of a Magento Abstract class,  you can stop now and save yourself some headaches.  Magento Abstract classes are not something you can do a rewrite on.

The only way to get it to work is to make a copy of the file in your local folder of app/code/local

Here is how I did an overload of Mage_Rule_Model_Abstract:

Step 1 Create a file app/code/local/Mage/Rule/Model/Abstract.php

Step 2 copy the contents from app/code/core/Mage/Rule/Model/Abstract.php and paste it into our new file we created on Step 1.

Step 3 test to see if its using our file instead of the core file, if you have a debugger, like the one in PHPstorm but a break point and execute the code!

You should now be all set and using our version of the abstract class instead of the core file, now you can edit it to suit your needs, like I did for allowing a negative number in the shopping cart rules.

How to create an "extra fee" or a negative amount in Shopping Cart Price Rule

If you have ever needed to create a shopping cart price rule but the value needed to be negative, Magento prevents this by default.  You may want this to create an extra fee based on some rules like if there is a certain sku in the cart, or whatever.

To overcome Magento's check to see if that number entered is negative we have to overload one magento core file, and create a rewrite of another.  Hold on to your hat, here we go.

Overload a core Magento abstract class

Step 1 Create a file app/code/local/Mage/Rule/Model/Abstract.php

Step 2 copy the contents from app/code/core/Mage/Rule/Model/Abstract.php and paste it into our new file we created on Step 1.

Rewrite Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_Actions

Step 1 Create a module instantiation file app/etc/modules/Russellalbin_Adminhtml.xml

Read more

Magento - How to create custom Customer Tab and submit a form

If you ever needed to create a custom Customer tab and put some information there, as well as submit a form, this should give you enough information to accomplish this task.

Create Module declaration

app/etc/modules/Russellalbin_Customertab.xml

<?xml version="1.0"?>
<config>
<modules>
<Russellalbin_Customertab>
<active>true</active>
<codePool>local</codePool>
</Russellalbin_Customertab>
</modules>
</config>

Create the module configuration file

Read more

Zend framework 1.x getting database config from application.ini

$configuration = new Zend_Config_Ini(
APPLICATION_PATH.'/configs/application.ini',
'development'
);
$host = $configuration->resources->db->params->host;
$pass = $configuration->resources->db->params->password;
$user = $configuration->resources->db->params->username;
$dbname = $configuration->resources->db->params->dbname;

$db = Zend_Db::factory('Pdo_Mysql', array(
'host' => $host,
'username' => $user,
'password' => $pass,
'dbname' => $dbname
));

Read more

Setting up a NEW MySQL Master Slave replication

Step 1: SSH into both servers

Step 2: Install mysql 

sudo apt-get install mysql-server -y

Step 3: Master Server update to my.cnf. If your my.cnf has 

#server-id              = 1
#log_bin                = /var/log/mysql/mysql-bin.log

Simply remove the # and then restart your mysql server and if not, just add them it should look like this:

Read more