Magento Get arg_name in observer - magento

i can set up a observer to listen when one of the controller method tigger, however, i want to pass the parameter to the observer, how can i get the parameter in observer? arg_value
thanks a lot
<events>
<controller_action_predispatch_mycompany_mymodule_controllername_recalculation>
<observers>
<mycompany_mymodule>
<class>Mycompany_Mymodule_Model_Observer</class>
<method>processgo</method>
<args>
<arg_name>arg_value</arg_name>
</args>
</mycompany_mymodule>
</observers>
</controller_action_predispatch_mycompany_mymodule_controllername_recalculation>
</events>

Please try something like following
<events>
<event_to_observe>
<observers>
<observer_name>
<type>singleton</type>
<class>Namespace_Module_Model_ObserverClass</class>
<method>observerMethod</method>
<args>
<arg_name>arg_value</arg_name>
</args>
</observer_name>
</observers>
</event_to_observe>
</events>
<?php
/**
* Observer class
*/
class Namespace_Module_Model_ObserverClass {
/**
* Observer method
*
* #param Varien_Event_Observer $observer
* #return void
*/
public function observerMethod(Varien_Event_Observer $observer) {
$args = Mage::helper('ecmessenger')->getObserverArgs($observer, get_class($this), __FUNCTION__);
Mage::log($args, null, 'observer.log');
}
}
Make sure here Mage::helper('ecmessenger') is the helper that you need to create and specify in config.xml
Let me know if you have any query

Related

Add custom fields to payment method

I have duplicated the checkmo doing the following below
Duplicate it as follows checkmo to checkmonew. I am using Magento version 1.9.3
Step 1 : mage/payment/block/forms + info : duplicate checkmo.php to checkmonew.php (rename inside checkmo to checkmonew)
Step 2 : mage/payment/etc/config.xml + system.xml : duplicate the checkmo parts (and rename it to checkmonew)
Step 3 : mage/payment/model/method : duplicate checkmo.php to checkmonew.php (rename inside checkmo to checkmonew)
Step 4 : design/adminhtml/default/default/template/payment/form + info : duplicate checkmo.php to checkmonew.php (rename inside checkmo to checkmonew)
Step 5 : design/frontend/base/default/template/payment/form + info :
duplicate checkmo.php to checkmonew.php (rename inside checkmo to checkmonew)
Now, this all seems to work but for some reason only on the backend but checkmo shows in the frontend, no problem.
I also want to add cc type option in the new payment method. I would prefer it not to be a drop down just a selection from the list of cards which are in cc type which is used in the CC payment method.
Thanks
admin inmage
code
block - info
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* #category Mage
* #package Mage_Payment
* #copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* #license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class Mage_Payment_Block_Info_Cashmonew extends Mage_Payment_Block_Info
{
protected $_payableTo;
protected $_mailingAddress;
protected function _construct()
{
parent::_construct();
$this->setTemplate('payment/info/Cashmonew.phtml');
}
/**
* Enter description here...
*
* #return string
*/
public function getPayableTo()
{
if (is_null($this->_payableTo)) {
$this->_convertAdditionalData();
}
return $this->_payableTo;
}
protected function _prepareSpecificInformation($transport = null)
{
if (null !== $this->_paymentSpecificInformation) {
return $this->_paymentSpecificInformation;
}
$transport = parent::_prepareSpecificInformation($transport);
$data = array();
if ($ccType = $this->getCcTypeName()) {
$data[Mage::helper('payment')->__('Credit Card Type')] = $ccType;
}
if ($this->getInfo()->getCcLast4()) {
$data[Mage::helper('payment')->__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
}
if (!$this->getIsSecureMode()) {
if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
$data[Mage::helper('payment')->__('Switch/Solo/Maestro Issue Number')] = $ccSsIssue;
}
$year = $this->getInfo()->getCcSsStartYear();
$month = $this->getInfo()->getCcSsStartMonth();
if ($year && $month) {
$data[Mage::helper('payment')->__('Switch/Solo/Maestro Start Date')] = $this->_formatCardDate($year, $month);
}
}
return $transport->setData(array_merge($data, $transport->getData()));
}
/**
* Enter description here...
*
* #return string
*/
public function getMailingAddress()
{
if (is_null($this->_mailingAddress)) {
$this->_convertAdditionalData();
}
return $this->_mailingAddress;
}
/**
* Enter description here...
*
* #return Mage_Payment_Block_Info_Cashmonew
*/
protected function _convertAdditionalData()
{
$details = false;
try {
$details = Mage::helper('core/unserializeArray')
->unserialize($this->getInfo()->getAdditionalData());
} catch (Exception $e) {
Mage::logException($e);
}
if (is_array($details)) {
$this->_payableTo = isset($details['payable_to']) ? (string) $details['payable_to'] : '';
$this->_mailingAddress = isset($details['mailing_address']) ? (string) $details['mailing_address'] : '';
} else {
$this->_payableTo = '';
$this->_mailingAddress = '';
}
return $this;
}
public function toPdf()
{
$this->setTemplate('payment/info/pdf/Cashmonew.phtml');
return $this->toHtml();
}
}
block - form
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* #category Mage
* #package Mage_Payment
* #copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* #license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class Mage_Payment_Block_Form_Cashmonew extends Mage_Payment_Block_Form
{
protected function _construct()
{
parent::_construct();
$this->setTemplate('payment/form/Cashmonew.phtml');
}
}
/**
* Retrieve availables credit card types
*
* #return array
*/
public function getCcAvailableTypes()
{
$types = $this->_getConfig()->getCcTypes();
if ($method = $this->getMethod()) {
$availableTypes = $method->getConfigData('cctypes');
if ($availableTypes) {
$availableTypes = explode(',', $availableTypes);
foreach ($types as $code=>$name) {
if (!in_array($code, $availableTypes)) {
unset($types[$code]);
}
}
}
}
return $types;
}
etc - config
<?xml version="1.0"?>
<!--
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* #category Mage
* #package Mage_Payment
* #copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* #license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
<config>
<modules>
<Mage_Payment>
<version>1.6.0.0</version>
</Mage_Payment>
</modules>
<global>
<models>
<payment>
<class>Mage_Payment_Model</class>
</payment>
</models>
<resources>
<payment_setup>
<setup>
<module>Mage_Payment</module>
</setup>
</payment_setup>
</resources>
<blocks>
<payment>
<class>Mage_Payment_Block</class>
</payment>
</blocks>
<payment>
<checkmonew>
<types>
<AE>
<code>AE</code>
<name>American Express</name>
<order>0</order>
</AE>
<VI>
<code>VI</code>
<name>Visa</name>
<order>10</order>
</VI>
<MC>
<code>MC</code>
<name>MasterCard</name>
<order>20</order>
</MC>
<DI>
<code>DI</code>
<name>Discover</name>
<order>30</order>
</DI>
<SM>
<code>SM</code>
<name>Maestro/Switch</name>
<order>40</order>
</SM>
<SO>
<code>SO</code>
<name>Solo</name>
<order>45</order>
</SO>
<JCB>
<code>JCB</code>
<name>JCB</name>
<order>50</order>
</JCB>
<OT>
<code>OT</code>
<name>Other</name>
<order>1000</order>
</OT>
</types>
</checkmonew>
<groups>
<offline>Offline Payment Methods</offline>
</groups>
</payment>
<payment>
<cc>
<types>
<AE>
<code>AE</code>
<name>American Express</name>
<order>0</order>
</AE>
<VI>
<code>VI</code>
<name>Visa</name>
<order>10</order>
</VI>
<MC>
<code>MC</code>
<name>MasterCard</name>
<order>20</order>
</MC>
<DI>
<code>DI</code>
<name>Discover</name>
<order>30</order>
</DI>
<SM>
<code>SM</code>
<name>Maestro/Switch</name>
<order>40</order>
</SM>
<SO>
<code>SO</code>
<name>Solo</name>
<order>45</order>
</SO>
<JCB>
<code>JCB</code>
<name>JCB</name>
<order>50</order>
</JCB>
<OT>
<code>OT</code>
<name>Other</name>
<order>1000</order>
</OT>
</types>
</cc>
<groups>
<offline>Offline Payment Methods</offline>
</groups>
</payment>
<events>
<sales_order_save_before>
<observers>
<payment_sales_order_save_before>
<class>payment/observer</class>
<method>salesOrderBeforeSave</method>
</payment_sales_order_save_before>
</observers>
</sales_order_save_before>
<sales_order_payment_save_before>
<observers>
<payment_before_save>
<class>payment/observer</class>
<method>beforeOrderPaymentSave</method>
</payment_before_save>
</observers>
</sales_order_payment_save_before>
<sales_order_status_unassign_before>
<observers>
<payment_order_status_unassign_before>
<class>payment/observer</class>
<method>beforeSalesOrderStatusUnassign</method>
</payment_order_status_unassign_before>
</observers>
</sales_order_status_unassign_before>
</events>
</global>
<frontend>
<translate>
<modules>
<Mage_Payment>
<files>
<default>Mage_Payment.csv</default>
</files>
</Mage_Payment>
</modules>
</translate>
<events>
<catalog_product_type_prepare_full_options>
<observers>
<payment_recurring_profile_prepare_options>
<class>payment/observer</class>
<method>prepareProductRecurringProfileOptions</method>
</payment_recurring_profile_prepare_options>
</observers>
</catalog_product_type_prepare_full_options>
</events>
<layout>
<updates>
<payment module="Mage_Payment">
<file>payment.xml</file>
</payment>
</updates>
</layout>
</frontend>
<adminhtml>
<translate>
<modules>
<Mage_Payment>
<files>
<default>Mage_Payment.csv</default>
</files>
</Mage_Payment>
</modules>
</translate>
</adminhtml>
<default>
<payment>
<ccsave>
<active>1</active>
<cctypes>AE,VI,MC,DI</cctypes>
<model>payment/method_ccsave</model>
<order_status>pending</order_status>
<title>Credit Card (saved)</title>
<allowspecific>0</allowspecific>
<group>offline</group>
</ccsave>
<checkmo>
<active>1</active>
<model>payment/method_checkmo</model>
<order_status>pending</order_status>
<title>Check / Money order</title>
<allowspecific>0</allowspecific>
<group>offline</group>
</checkmo>
<checkmonew>
<active>1</active>
<cctypes>AE,VI,MC,DI</cctypes>
<model>payment/method_checkmonew</model>
<order_status>pending</order_status>
<title>Card POS</title>
<allowspecific>0</allowspecific>
<group>offline</group>
</checkmonew>
<free>
<active>1</active>
<model>payment/method_free</model>
<order_status>pending</order_status>
<title>No Payment Information Required</title>
<allowspecific>0</allowspecific>
<sort_order>1</sort_order>
<group>offline</group>
</free>
<purchaseorder>
<active>0</active>
<model>payment/method_purchaseorder</model>
<order_status>pending</order_status>
<title>Purchase Order</title>
<allowspecific>0</allowspecific>
<group>offline</group>
</purchaseorder>
<banktransfer>
<active>0</active>
<model>payment/method_banktransfer</model>
<order_status>pending</order_status>
<title>Bank Transfer Payment</title>
<allowspecific>0</allowspecific>
<group>offline</group>
</banktransfer>
<cashondelivery>
<active>0</active>
<model>payment/method_cashondelivery</model>
<order_status>pending</order_status>
<title>Cash On Delivery</title>
<allowspecific>0</allowspecific>
<group>offline</group>
</cashondelivery>
</payment>
</default>
</config>

rewrite cart url is not working in magento

I want to re-write checkout cart url. I had created a module but it is not working. I had created config.xml and Url.php in model but it didn't succeed. my code is: etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Ghrix_Newcart>
<version>1.0.0</version>
</Ghrix_Newcart>
</modules>
<global>
<rewrite>
<ghrix_newcart_checkout_cart>
<from><![CDATA[#^/checkout/winkelwagen#]]></from>
<to><![CDATA[#^/checkout/cart#]]></to>
</ghrix_newcart_checkout_cart>
</rewrite>
<models>
<ghrix_newcart>
<class>Ghrix_Newcart_Model</class>
</ghrix_newcart>
<core>
<rewrite>
<url>Ghrix_Newcart_Model_Url</url>
</rewrite>
</core>
</models>
</global>
</config>
in Model/Url.php
<?php
class Ghrix_Newcart_Model_Url extends Mage_Core_Model_Url {
/**
* Build url by requested path and parameters
*
* #param string|null $routePath
* #param array|null $routeParams
* #return string
*/
public function getUrl($routePath = null, $routeParams = null) {
if(strstr($routePath,'checkout')){
//echo $routePath.'--ss--<br />';
}
if ( $routePath == 'checkout/cart' ) {
$routePath = 'checkout/cart';
}
return parent::getUrl($routePath, $routeParams);
}
}
?>
I had created a function properly but it didn't work for me. I want my checkout/cart url should be checkout/winkelwagen Please suggest what can I do.
I would probably approach this in a less intrusive way, using Magento’s event observer system. What you could do is redirect all requests to the checkout/cart route to your new route checkout/winkelwagen with something like this:
etc/config.xml
<frontend>
<events>
<controller_action_predispatch_checkout_cart_index>
<observers>
<redirectCart>
<class>Ghrix_Newcart_Model_Observer</class>
<method>redirectCart</method>
</redirectCart>
</observers>
</controller_action_predispatch_checkout_cart_index>
</events>
</frontend>
Model/Observer.php
public function redirectCart(Varien_Event_Observer $observer)
{
Mage::app()->getResponse()->setRedirect('/checkout/winkelwagen')->sendResponse();
exit;
}

Magento - automatically redirecting empty parent categories to the first child category

I need to redirect pages that contain no products to the first child category URL containing products (if the child category exists)
Since I need to do this only if the category contains no products, I'm not able to do this via .htaccess
Does anyone have any ideas on how this can be achieved in Magento?
I'm not having much luck hunting through Google.
Haven't checked it. You should put it in your view.phtml.
$currentCategory = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
$productCheck = Mage::getModel('catalog/category')->load($currentCategory)
->getProductCollection();
if (count($productCheck) < 1) {
echo '<script type="text/javascript">
window.location = "' . Mage::getUrl('somewhere') . '"
</script>';
}
You can use an observer. You could edit/create a local catalog module and try this:
1) Define observer on your config.xml:
<?xml version="1.0"?>
<config>
<!--(...)-->
<global>
<!--(...)-->
<events>
<catalog_controller_category_init_after>
<observers>
<yourcompany_catalog>
<type>singleton</type>
<class>yourcompany_catalog/observer</class>
<method>categoryRedirect</method>
</yourcompany_catalog>
</observers>
</catalog_controller_category_init_after>
</events>
<!--(...)-->
</global>
<!--(...)-->
</config>
2) Your observer method can be something like this:
<?php
class GraspingMagento_SocialShare_Model_Observer
{
/**
* #param Varien_Event_Observer $observer
* #return void
*/
public function categoryRedirect(Varien_Event_Observer $observer)
{
/** #var Mage_Catalog_Model_Category $category */
$category = $observer->getData('category');
if ($category->getProductCollection()->count() > 0) {
// Category has products, no need to redirect
return;
}
/** #var Mage_Catalog_Model_Resource_Category_Collection $childrenCategories */
$childrenCategories = $category->getChildrenCategories();
/** #var Mage_Catalog_CategoryController $controller */
$controller = $observer->getControllerAction();
foreach ($childrenCategories as $childCategory) {
/** #var Mage_Catalog_Model_Category $childCategory */
if ($childCategory->getProductCollection()->count() > 0) {
$controller->getResponse()->setRedirect($childCategory->getData('request_path'));
break;
}
}
}
}
This will verify that your current category has no products. If it doesn't, it will try to find a direct child that has products, and redirect to it.

Magento 1.7: Adding a custom promotion

I would like to add a custom promotion condition to Magento 1.7. It should be possible to apply a promotion based on a custom attribute in the shipping address of the customer. Its actually quite basic: if the attribute is filled, the promotion should apply, not more.
It should appear as a seperate condition point of the Cart Attributes like "Shipping Postcode" or "Shipping Region"
What would help as well: How are the standard Cart Promotion conditions are implemented or where to look for more information on this topic.
I searched the internet for quite a while now, and I'm really stuck. Your help is highly appreciated!
Thx a lot
Ok, I found a more or less working solution I want to share here, in case sombody else is needing this:
I created a module, that is introducing a new Condition into the promotions. The missing peace in order to achieve this was to do it via an observer.
First the config <path to module>\etc\config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<HauteNature_FamilienkarteHessen>
<version>1.0.0</version>
</HauteNature_FamilienkarteHessen>
</modules>
<admin>
<fieldsets>
<customer_dataflow>
<building>
<billing>1</billing>
<shipping>1</shipping>
</building>
</customer_dataflow>
</fieldsets>
</admin>
<global>
<models>
<familienkartehessen>
<class>HauteNature_FamilienkarteHessen_Model</class>
</familienkartehessen>
</models>
<helpers>
<familienkartehessen>
<class>HauteNature_FamilienkarteHessen_Helper</class>
</familienkartehessen>
</helpers>
<events>
<salesrule_rule_condition_combine>
<observers>
<add_condition_to_sales_rule>
<class>familienkartehessen/observer</class>
<method>addConditionToSalesRule</method>
</add_condition_to_sales_rule>
</observers>
</salesrule_rule_condition_combine>
</events>
<resources>
<familienkartehessen_setup>
<setup>
<module>HauteNature_FamilienkarteHessen</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</familienkartehessen_setup>
</resources>
<fieldsets>
<sales_copy_order_billing_address>
<familiycarthessen><to_order>*</to_order></familiycarthessen>
</sales_copy_order_billing_address>
<sales_copy_order_shipping_address>
<familiycarthessen><to_order>*</to_order></familiycarthessen>
</sales_copy_order_shipping_address>
<sales_convert_quote_address>
<familiycarthessen><to_order_address>*</to_order_address><to_customer_address>*</to_customer_address></familiycarthessen>
</sales_convert_quote_address>
<sales_convert_order_address>
<familiycarthessen><to_quote_address>*</to_quote_address></familiycarthessen>
</sales_convert_order_address>
<customer_address>
<familiycarthessen><to_quote_address>*</to_quote_address></familiycarthessen>
</customer_address>
<checkout_onepage_billing>
<familiycarthessen><to_customer>*</to_customer></familiycarthessen>
</checkout_onepage_billing>
</fieldsets>
</global>
</config>
I think this part is hoocking it to the magento Interface:
<salesrule_rule_condition_combine>
<observers>
<add_condition_to_sales_rule>
<class>familienkartehessen/observer</class>
<method>addConditionToSalesRule</method>
</add_condition_to_sales_rule>
</observers>
</salesrule_rule_condition_combine>
Second the observer, quite simple, just adding the menu point to the UI and linking it to the condition: <path to module>\Model\Observer.php:
class HauteNature_FamilienkarteHessen_Model_Observer extends Mage_Core_Model_Abstract {
/**
* Event: salesrule_rule_condition_combine
*
* #param $observer
*/
public function addConditionToSalesRule($observer) {
$additional = $observer->getAdditional();
$conditions = (array) $additional->getConditions();
$conditions = array_merge_recursive($conditions, array(
array('label'=>Mage::helper('familienkartehessen')->__('Familienkarte Hessen'), 'value'=>'familienkartehessen/condition_familienkarte'),
));
$additional->setConditions($conditions);
$observer->setAdditional($additional);
return $observer;
}
}
And finally the custom Condition Class that actually does the work <path to module>\Model\Condition/Familienkarte.php:
class HauteNature_FamilienkarteHessen_Model_Condition_Familienkarte extends Mage_Rule_Model_Condition_Abstract {
/**
* #TODO for whatever this it, check it and afterwards document it!
*
* #return Hackathon_DiscountForATweet_Model_Condition_Tweet
*/
public function loadAttributeOptions() {
$attributes = array(
'fkhContent' => Mage::helper('familienkartehessen')->__('Familienkarte Hessen')
);
$this->setAttributeOption($attributes);
return $this;
}
/**
* #TODO for whatever this it, check it and afterwards document it!
*
* #return mixed
*/
public function getAttributeElement() {
$element = parent::getAttributeElement();
$element->setShowAsText(true);
return $element;
}
/**
* #TODO for whatever this it, check it and afterwards document it!
*
* #return string
*/
public function getInputType() {
switch ($this->getAttribute()) {
case 'fkhContent':
return 'boolean';
}
return 'string';
}
/**
* #TODO for whatever this it, check it and afterwards document it!
* #return string
*/
public function getValueElementType() {
return 'text';
}
/**
* Validate FamiliencarteHessen Rule Condition
*
* #param Varien_Object $object
*
* #return bool
*/
public function validate(Varien_Object $object) {
/* here should be something meaningful */
$address = $object;
if (!$address instanceof Mage_Sales_Model_Quote_Address) {
if ($object->getQuote()->isVirtual()) {
$address = $object->getQuote()->getBillingAddress();
}
else {
$address = $object->getQuote()->getShippingAddress();
}
}
return $this->validateAttribute(trim($address->getFamiliycarthessen()));
}
}
If anyone of you has comments on this code, I would be greatfull to hear them.
Best wishes
Andreas

make a new product active by default in magento

When duplicating a product in the backend in magento the new product status is Disabled by default. That confuses the store admins who expect the product to show on the frontend.
How can I make the product status Enabled by default?
THanks
In your custom module you need to:
in config.xml file:
<config>
<adminhtml>
<events>
<catalog_model_product_duplicate>
<observers>
<custom_catalog_product_duplicate>
<class>custom_module/observer</class>
<method>catalogModelProductDuplicate</method>
</custom_catalog_product_duplicate>
</observers>
</catalog_model_product_duplicate>
</events>
</adminhtml>
</config>
Create an observer class with method like this:
class Custom_Module_Model_Observer
{
/**
* Prepare product for duplicate action.
*
* #param Varien_Event_Observer $observer
* #return object
*/
public function catalogModelProductDuplicate(Varien_Event_Observer $observer)
{
$newProduct = $observer->getEvent()->getNewProduct();
$newProduct->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
return $this;
}
}

Resources