R.I.P Mega Upload

As you all are probably already aware, MegaUpload has been taken down by the US Government. As you also may know, pretty much all the downloads here were hosted with them. I will try with my limited spare time to move all these downloads to another file provider.

Anyone have any suggestions?

Creating a Console Command / Task in Symfony2 with Doctrine

This is a basic console command/task that you can create for your bundles in the Symfony2 framework. Tested with 2.0.4

First, create your console command class file in Symfony/src/<MyNamespace>/<MyBundle>/Command/<CommandName>Command.php

For example, if my namespace is Spliced and my bundle name is AwesomeBundle and the command I want to create is going to be called Awesome, then I would create this file:

Symfony/src/Spliced/AwesomeBundle/Command/AwesomeCommand.php

Now, set up your class to look like this, just replace your namespaces and bundles. I will use the above exampled namespace/bundle:


namespace Spliced\AwesomeBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class AwesomeCommand extends ContainerAwareCommand
{
	/**
	 * Initialize whatever variables you may need to store beforehand, also load
         * Doctrine from the Container
	 */
    protected function initialize(InputInterface $input, OutputInterface $output)
    {
        parent::initialize($input, $output); //initialize parent class method

        $this->em = $this->getContainer()->get('doctrine')->getEntityManager(); // This loads Doctrine, you can load your own services as well
    }
     /**
    * Configure the task with options and arguments
    */
    protected function configure()
    {
        parent::configure();

        $this

        ->setName('spliced:awesome') // this is the command you would pass to console to run the command.
        ->setDescription('An example Awesome Command')    // Your Description

         // Add an Argument
        ->addArgument('argument_name', InputArgument::REQUIRED, 'Argument Description', 'Argument Default Value') 

       // Add an Option
        ->addOption('option', 'o', InputOption::PARAMETER_OPTIONAL, 'Option Description', 'Option Default Value'); // Add an Option

      // Here are some parameter requirement constants:  InputOption::PARAMETER_OPTIONAL, InputOption::PARAMETER_REQUIRED

    }
     /**
    * Our console/task logic
    */
    protected function execute(InputInterface $input, OutputInterface $output)
    {

        $options = $input->getOptions(); // load options passted from console

        /* DO YOUR AWESOME STUFF HERE */

		 //get Doctrine EntityManager we initialized  in the initialize method and get a Repository to do something useful maybe
		# $this->em->getRepository('SplicedAwesomeBundle:AwesomeSauce')->getAllAwsomeSauce();

        // Display Some Output
       $output->writeln('My Awesome Task Did Some Pretty Awesome Stuff!');

    }
}

Now if I were to go to a bash line in the Symfony root directory and use the command:

php app/console spliced:awesome

Then my console command will have been successfully executed. Good for when you need or prefer a command line routine.

Exclusive Discount on RAM Memory Upgrades

For a limited time, from now (August 28th 2011) until September 5th 2011 – I have 100 discount coupons available for use for anyone looking to save a little bit on some RAM.

Visit Quantum Technology for your RAM Memory and use the promotion code IDRISSDOTUS5 and you will recieve 5% off your ordered items (this excludes shipping, but they offer FREE shipping anyway)

I will probably have access to better promotions here in a few weeks so check back.

THIS PROMO HAS ENDED

 

Looking for Memory or your Computer or Mobile Device?

Check out Quantum Technologies. A new online retailer for all types of memory. You can find great deals on DDR2 and DDR3 Memory for your Laptop or Desktop. You can even find old stuff (for those hobbyists and collectors of old devices ) . And of course flash memory for your mobile devices.

Free shipping within the USA and affordable flat rates for priority, express, and international . Be sure to check back here for special offers only available on my blog!

http://www.qtmemory.com

Would love some of your feedback or reviews/opinions.

Online MEID/ESN Converter Now Available w/ MetroPCS SPC Calculation

This past weekend I decided to convert the Android MEID Converter into a PHP Version. This online conversion tool is free and you can visit http://www.meidconverter.net to use this online tool.

It will convert either a ESN or MEID in HEX or DEC. pESN is also calculated as well as the MetroPCS SPC.

Written in 100% PHP. Source code is not currently open, but will probably end up on GitHub here any time soon.

MetroPCS PRL AWS Updated 3018

Download

http://www.idriss.us/downloads/index.php?id=41

Magento Extension Payment Module Pay By Phone

For a project at work I had to create a pay by phone payment module for Magento. I decided to post it here in case anyone can find use from it.

Download the archive from the link at the bottom of the post, then extract it to the root of your magento installation.

It should automatically register itself and you can enable it and configure it in the administration area of magento ( System -> Configuration -> Payment Methods )

By default all orders placed with this payment type are set as pending.

Download Pay By Phone Magento Extension

Released under theĀ  DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE (WFPL) – For more information about this license please see http://sam.zoy.org/wtfpl

Programmatically Creating Products in Magento 1.4.x

UPDATE: This works on 1.5 as well

I was working on a project that imports mass products into magento based on a table in a MySQL Database. If you are looking to create a script to do this, you can easily accomplish that with a script like the following (of course with some stuff to like.. load your data, and maybe and a foreach loop :p ):

// First we load Magento. This applies to loading magento if you are  not going to be making some sort of extension/module to accomplish this for you.

require_once('/path/to/magento/app/Mage.php');
umask(0);

// Set an Admin Session
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
Mage::getSingleton('core/session', array('name'=>'adminhtml'));
$userModel = Mage::getModel('admin/user');
$userModel->setUserId(1);
$session = Mage::getSingleton('admin/session');
$session->setUser($userModel);
$session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());

// Then we see if the product exists already, by SKU since that is unique to each product
$product = Mage::getModel('catalog/product')
   ->loadByAttribute('sku',$_product['sku']); 

if(!$product){
  	// product does not exist so we will be creating a new one.
    // i noticed some fields will give a database error if they are set when existing. These are the fields I found to work successfully

  	$product = new Mage_Catalog_Model_Product();

  	$product->setTypeId('simple');
	$product->setWeight(1.0000);
	$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
	$product->setStatus(1);
	$product->setSku('UNIQUESKUHERE');
	$product->setTaxClassId(0);
	$product->setWebsiteIDs(array(0)); // your website ids
	$product->setStoreIDs(array(0));  // your store ids
	$product->setStockData(array(
		'is_in_stock' => 1,
		'qty' => 99999,
		'manage_stock' => 0,
	));
}

// set the rest of the product information here that can be set on either new/update
$product->setAttributeSetId(9); // the product attribute set to use
$product->setName('Product Title');
$product->setCategoryIds(array(0,1,2,3)); // array of categories it will relate to
$product->setDescription('Description');
$product->setShortDescription('Short Description');
$product->setPrice(9.99);

// set the product images as such
// $image is a full path to the image. I found it to only work when I put all the images I wanted to import into the {magento_path}/media/catalog/products - I just created my own folder called import and it read from those images on import.
$image = '/path/to/magento/media/catalog/products/import/image.jpg';

$product->setMediaGallery (array('images'=>array (), 'values'=>array ()));
$product->addImageToMediaGallery ($image, array ('image'), false, false);
$product->addImageToMediaGallery ($image, array ('small_image'), false, false);
$product->addImageToMediaGallery ($image, array ('thumbnail'), false, false);

// setting custom attributes. for example for a custom attribute called special_attribute
// special_attribute will be used on all examples below for the various attribute types
$product->setSpecialAttribute('value here');

// setting a Yes/No Attribute
$product->setSpecialField(1);

// setting a Selection Attribute
$product->setSpecialAttribute($idOfAttributeOption); //specify the ID of the attribute option, eg you creteated an option called Blue in special_attribute it was assigned an ID of some number. Use that number.

// setting a Mutli-Selection Attribute
$data['special_attribute'] = '101 , 102 , 103'; // coma separated string of option IDs. As ID , ID (mind the spaces before and after coma, it worked for me like that)
$product->setData($data);

try{
	$product->save();

} catch(Exception $e){
	echo $e->getMessage();
	//handle your error
}

I found how to do this on various pages such as some answers in http://www.stackoverflow.com and as well as some topics on the magento forum. However there are bits and pieces I got from some other websites which I did not bookmark and am sorry if I leave you out of the following links as I just put this up cause I though it might be useful for someone looking to add products with lots of attributes and pictures and I just kinda copied stuff out some of my code for example purposes.

http://rocinantesoftware.blogspot.com/2009/06/programmatically-importing-product-with.html

http://activecodeline.net/programatically-manually-creating-simple-magento-product

MetroPCS PRL 3017

http://www.idriss.us/downloads/index.php?id=39

Downgrading or Restoring LG Optimus M LGMS690 to Android 2.2 from 2.2.1

First things first. Download all that you will need:

  • LGMS690 Restore TOT File
  • LG Optimus M USB Driver
  • Download LGNPST Store and Lab (1.2)
    • Includes These Components:
      • LGNPST_Components_Ver_3_0_5_0
      • LGNPST_Components_Ver_3_0_6_0
      • LGNPST_Components_Ver_3_0_12_0
      • LGNPST_Components_Ver_4_0_17_0
      • LGNPST_Components_Ver_4_0_22_0
      • LGNPST_Components_Ver_5_0_12_0
    • Includes These Generic Modules:
      • LGNPST_GenericModel_Ver_2_0_29_0
      • LGNPST_GenericModels_Ver_3_0_7_0
      • LGNPST_GenericModels_Ver_3_0_12_0
      • LGNPST_GenericModels_Ver_3_0_17_0
      • LGNPST_GenericModels_Ver_4_0_7_0
      • LGNPST_GenericModels_Ver_4_0_9_0
      • LGNPST_GenericModels_Ver_5_0_10_0

Now that you have everything downloaded lets get started by installing LGNPST Store and Lab. The installers are in the root of the LGNPST archive you downloaded above.After they are done installing, install all the Components and GenericModels.

Copy the LGNPST_CT.exe to the Install Directory (Default is C:\LG Electronics\LGNPST)

After you have installed both Store and Lab as well as the GenericModels and Components, install the drivers if you have not already.

After that you will want to run the Right_Click_Register_DLL.reg so we can register some DLLs if need be.

In the Device DDLs folder there is a MS690.dll file. Copy that to LGNPST Diectory/models (e.g. C:\LG Electronics\LGNPST\Models). Once it is copied, Right Click the file and select Register DLL.

Now extract LGMS690 Restore TOT File to anywhere you want, just remember where. Desktop is a good place.

Once you have installed all the above you will probably want to restart your computer. Once your computer reboots lets open LGNPST. Once it loads up, connect your Optimus M to your computer.

In LGNPST you will see your phone listed, with the Model Reading MS690 and that it is connected.

In the Provision tab, make sure UPGRADE is selected. Where you see BIN File, press the folder icon to browse your PC for the TOT file you extracted before you opened up LGNPST. In the file name field, type *.* and press enter. The TOT file will show up. Select it and press Open. Now just press START and it will restore your device to 2.2 Froyo.

Thats is it. You can now root the phone with z4root.

I have tested this on a 2.2 Device as well as a 2.2.1 device, and it works.

Here is the TOT for the Sprint Optimus S (LGLS670)