Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to test a magento class thru command line for Ozzy
<?php
require_once 'app/Mage.php';
Mage::app('admin','store');
// this class is loaded in app/code/local/Paquin/Ozzy.php
$ozzy = new Paquin_Ozzy('json2.json');
var_dump($ozzy->categoryIdsToShow());
@joshribakoff

This comment has been minimized.

Copy link
Owner Author

commented Oct 9, 2013

<?php
class Paquin_Ozzy
{
    function categoryIdsToShow($userID)
    {
        $cacheFile = Mage::getBaseDir()."/var/cache/$userID";

        if(file_exists($cacheFile)) {
            echo "cache hit!\n";
            return unserialize(file_get_contents($cacheFile));
        }

        $array = $this->hitTheAPI();
        file_put_contents($cacheFile, serialize($array));
        return $array;
    }

    function hitTheAPI()
    {
        echo "API hit!\n";
        return array(1,2,3);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.