2017 © Pedro Peláez
 

magento-module magento-shell

Magento Improved Shell

image

steverobbins/magento-shell

Magento Improved Shell

  • Wednesday, June 10, 2015
  • by steverobbins
  • Repository
  • 6 Watchers
  • 51 Stars
  • 11 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 10 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Magento Shell

Join the chat at https://gitter.im/steverobbins/Magento-Shell, (*1)

Master Build Status Master Code Quality, (*2)

OMG COLORS

Drool, (*3)

Add some style to your Magento scripts., (*4)

Sample, (*5)

Usage

Extend the shell/local/abstract.php class and put your logic in the run() method, like you normally would with a Magento shell script., (*6)

Output

Instead of echoing, use the $this->log object. You can output messages using one of Zend_Log's levels, (*7)

<?php

class Zend_Log
{
    const EMERG   = 0;  // Emergency: system is unusable
    const ALERT   = 1;  // Alert: action must be taken immediately
    const CRIT    = 2;  // Critical: critical conditions
    const ERR     = 3;  // Error: error conditions
    const WARN    = 4;  // Warning: warning conditions
    const NOTICE  = 5;  // Notice: normal but significant condition
    const INFO    = 6;  // Informational: informational messages
    const DEBUG   = 7;  // Debug: debug messages
}

Example:, (*8)

<?php

require_once 'abstract.php';

class Local_Shell_MyScript extends Local_Shell_Abstract
{
    public function run()
    {
        $this->log->debug('Hello World!');
    }
}

Progress Bar

Create a progress bar with $bar = $this->progressBar($count);, where $count is an integer of how many items you will iterate over. $bar->update($i); as you walk through, then $bar->finish(); when complete., (*9)

Example:, (*10)

<?php

require_once 'abstract.php';

class Local_Shell_MyScript extends Local_Shell_Abstract
{
    public function run()
    {
        $collection = Mage::getModel('catalog/product')->getCollection();
        $count      = $collection->count();
        $bar        = $this->progressBar($count);
        $i          = 0;
        foreach ($collection as $product) {
            $product->setDescription(strip_tags($product->getDescription()))
                ->save();
            $bar->update(++$i);
        }
        $bar->finish();
    }
}

Logging

Output is automatically logged to var/log/shell_local_<scriptName>.log., (*11)

Alternatively, you can specify your own log file by setting the public $logFile variable in you script., (*12)

Support

Please create an issue for all bugs and feature requests, (*13)

Contributing

Fork this repository and send a pull request to the dev branch, (*14)

License

WTF Public License 2.0, (*15)

The Versions

10/06 2015

dev-master

9999999-dev

Magento Improved Shell

  Sources   Download

WTFPL

by Steve Robbins

magento

09/05 2015

dev-dev

dev-dev

Magento Improved Shell

  Sources   Download

WTFPL

by Steve Robbins

magento

09/05 2015

v1.0

1.0.0.0

Magento Improved Shell

  Sources   Download

WTFPL

by Steve Robbins

magento