A Better Way

  • Setting Default Product Values in Magento

    When creating new products in the Magento Admin, there are a few fields that you often fill out with the same values over and over again. Values such as the product status, tax class, stock availability, weight, etc. Wouldn't it be nice to have the system automatically assign default values to these fields every time you create a new product? Well good news! You can easily accomplish this by hooking into Magento's catalog_product_new_action event. I'm not going to cover how to create new modules in Magento, but here is the basic structure and files you'll need to accomplish this. Make sure to provide your own value anywhere Namespace is referenced below. /app/code/local/Namespace/Catalog/etc/config.xml /app/code/local/Namespace/Catalog/Model/Product/Observer.php

    1) Place the following in the config.xml file listed above.

    <?xml version="1.0"?>

    2) Place the following in the Observer.php file. Set product default values as desired.

    class Namespace_Catalog_Model_Product_Observer
    	public function catalog_product_new_action($observer) {
    		$product = $observer->getEvent()->getProduct();
    		$stockItem = Mage::getModel('cataloginventory/stock_item');
    		$stockItem->setData('is_in_stock', 1);
    		$stockItem->setData('qty', 1);

    3) Finally, you'll need to activate your new module by creating the file below with the following contents.


    <?xml version="1.0" encoding="UTF-8"?>
    Make sure to clear the Magento cache when you're done with this step as well! Check out the Magento wiki article on using Event/Observer for more information on this topic.

  • Get Hive Hosting

    We designed our Hive Hosting service to provide our clients with unparalleled business-class hosting and support. Contact us for Magento, WordPress, Drupal, Moodle or any custom hosting and we'll do the rest!

    WHY HOST WITH HIVE HOSTING? Because when you host with us, you get personalized, professional support that you can rely on at any hour, on any day of the week. We operate our servers on the same high-tech infrastructure as the big boys, but unlike a large hosting company, we don't have 50,000 clients to spread our attention amongst. You get direct access to our small and agile team, and if your site experiences problems at 11pm on a Saturday, you can be confident that your issue will be addressed promptly.

    Additionally, we've used our years of hosting experience to create a hosting infrastructure that is highly optimized for running complex sites with ease. The end result is blazing fast hosting backed by exceptional technical expertise and support.

    See http://www.swarmingtech.com/#hosting for more hosting details.

2 Item(s)