Skip to content

Instantly share code, notes, and snippets.

@joshribakoff
Created October 9, 2013 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshribakoff/6905615 to your computer and use it in GitHub Desktop.
Save joshribakoff/6905615 to your computer and use it in GitHub Desktop.
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
Copy link
Author

<?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