I created an catalog_product_save_before observer to update some attributes based on other attributes. Specifically, I use m2epro to update my ebay listings. Sometimes I want ebay to show less in stock than I actually have, so I created 2 new attributies, ebay_qty and ebay_max_qty.

In my observer, I have the following code:

$product = $observer->getEvent()->getProduct();
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);

$Qty = $stock->getQty();
$EBayQty = $Qty;
$MaxQty = $product->getEbayMaxQty();

if (($MaxQty > 0) && ($EBayQty > $MaxQty))
    $EBayQty = $MaxQty;

$product->setData('ebay_qty', $EBayQty);

This is grabbing the qty currently in the database. How do I get the new Qty about to be saved?

  • Someone suggested I add a tag m2epro. I rejected the idea because this topic has nothing to do with m2epro, I only included that information to give some background info on why I'm attempting to do what I'm doing so I didn't get useless answers about different ways to do something I'm not trying to do. I'm actually doing a lot more than I show here, but I showed enough to get the answer I need and not confuse the question with unneeded information. Had the person attempted to help answer the question, I would have given their suggestion more credit.
    – lv2fly
    Apr 19, 2016 at 5:12

2 Answers 2


Looks like no one has the answer to this. After searching for hours, I'm wondering if its even possible. I'm guessing it is as if I do a var_dump($product), Qty is listed, but can't figure out how to access it.

I did find a work around that might help someone else. I added a second function to the class and is called by the catalog_product_save_after observer

The config.xml file now looks like this:


I used the UpdateAttributes function and added the following function to the observer:

public function ebayQtyUpdate(Varien_Event_Observer $observer)
    $product = $observer->getEvent()->getProduct();

    $ID = Array($product->getId());
    $UpdateData = Array('ebay_qty'=>$this->GetEBayQty($product));

        ->updateAttributes($ID, $UpdateData, 0);
  • Please remove this answer and edit the other answer put all the information in a single answer, as if you were answering somebody else's question. Magento.SE is not a threaded discussion forum.
    – dotancohen
    Jul 10 at 8:15

Found the answer incase anyone can't figure this out. First, I found catalog_product_prepare_save was a better place to do this than catalog_product_save_before. Don't know why, but someone suggested it, it worked, so not questioning it.

What I was missing was

$request = $observer->getEvent()->getRequest();
$request->getPost('what you're looking for')

You can then override the submitted data before its saved with

$product->setData('YourAttribute', $NewValue);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.