Engine23

Development

Password protect a folder in Linux using .htaccess

What’s the easiest way to make an .htaccess file in Unix/Linux so that a directory is password protected? Suppose that your home directory is /home/matt and all your webstuff is in /var/www/protected/ . Follow these steps:

  1. Make an .htpasswd file. The htpasswd command in Unix does this. You should put the password file outside of your web directory. So a command like "htpasswd -bc /var/password/.htpasswd admin mysecretpassword" will create a new file using a username of admin and a password of mysecretpassword into the file /var/password/.htpasswd . At the prompt type "cat /var/password/.htpasswd" it will show you something like: "admin:E.mx8CsZffRI6".
  2. Make an .htaccess file located at /var/www/protected/.htaccess and use the following
    AuthUserFile /var/password/.htpasswd
    AuthName EnterPassword
    AuthType Basic
    require valid-user

Remove Yii pagination

In your controller when building the $dataProvider add 'pagination'=>false

$dataProvider=new CActiveDataProvider('ResidentLedger', array(
'criteria'=>$criteria,
'pagination'=> false,
));

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