Accessing data in catalog_product_save_before observerModify tax rate on cart quote items and recalculateWhat's the preferred way of storing static calculation results in Magento?Sort products in frontend catalog view based on which attribute set they belong toObserver on Adminhtml product grid not getting colectionDownloadable Product Links in Zero Subtotal Checkout Invoice EmailsHelp writing an observer the “Magento Way”Create Duplicate quote item instead of updating existing quote item for same productEvent for Sales Order Quote ItemHow to update Qty on product save action?Observer and event not working

Security Patch SUPEE-11155 - Possible issues?

Find the radius of the hoop.

Is there a legal way for US presidents to extend their terms beyond two terms of four years?

Will writing actual numbers instead of writing them with letters affect readership?

Can one use the present progressive or gerund like an adjective?

Word ending in "-ine" for rat-like

How could an armless race establish civilization?

How do we separate rules of logic from non-logical constraints?

What is "oversubscription" in Networking?

Using “ser” without "un/una"?

I need help with pasta

Does a return economy-class seat between London and San Francisco release 5.28 tonnes of CO2 equivalents?

Prime parity peregrination

Why would anyone even use a Portkey?

"Vector quantity" --More than two dimensions?

Does a Hand Crossbow with the Repeating Shot Infusion still require a Free Hand to use?

Sharing referee/AE report online to point out a grievous error in refereeing

What verb for taking advantage fits in "I don't want to ________ on the friendship"?

How do I ensure my employees don't abuse my flexible work hours policy?

Movie with Zoltar in a trailer park named Paradise and a boy playing a video game then being recruited by aliens to fight in space

Reusable spacecraft: why still have fairings detach, instead of open/close?

Who are these Discworld wizards from this picture?

Was it really unprofessional of me to leave without asking for a raise first?

Can you actually break an FPGA by programming it wrong?



Accessing data in catalog_product_save_before observer


Modify tax rate on cart quote items and recalculateWhat's the preferred way of storing static calculation results in Magento?Sort products in frontend catalog view based on which attribute set they belong toObserver on Adminhtml product grid not getting colectionDownloadable Product Links in Zero Subtotal Checkout Invoice EmailsHelp writing an observer the “Magento Way”Create Duplicate quote item instead of updating existing quote item for same productEvent for Sales Order Quote ItemHow to update Qty on product save action?Observer and event not working






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















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?










share|improve this question






















  • 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 '16 at 5:12

















0















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?










share|improve this question






















  • 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 '16 at 5:12













0












0








0








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?










share|improve this question














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?







event-observer catalog






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 18 '16 at 19:31









lv2flylv2fly

6613 bronze badges




6613 bronze badges












  • 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 '16 at 5:12

















  • 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 '16 at 5:12
















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 '16 at 5:12





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 '16 at 5:12










2 Answers
2






active

oldest

votes


















0














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:



 <events>
<catalog_product_save_before>
<observers>
<me_createebaydescription>
<class>me_createebaydescription/observer</class>
<method>ebayDescriptionUpdate</method>
<type>singleton</type>
</me_createebaydescription>
</observers>
</catalog_product_save_before>
<catalog_product_save_after>
<observers>
<me_createebaydescription>
<class>me_createebaydescription/observer</class>
<method>ebayQtyUpdate</method>
<type>singleton</type>
</me_createebaydescription>
</observers>
</catalog_product_save_after>
</events>


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));

Mage::getSingleton('catalog/product_action')
->updateAttributes($ID, $UpdateData, 0);






share|improve this answer
































    0














    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->setYourAttribute($NewValue);
    or
    $product->setData('YourAttribute', $NewValue);





    share|improve this answer

























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f111425%2faccessing-data-in-catalog-product-save-before-observer%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      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:



       <events>
      <catalog_product_save_before>
      <observers>
      <me_createebaydescription>
      <class>me_createebaydescription/observer</class>
      <method>ebayDescriptionUpdate</method>
      <type>singleton</type>
      </me_createebaydescription>
      </observers>
      </catalog_product_save_before>
      <catalog_product_save_after>
      <observers>
      <me_createebaydescription>
      <class>me_createebaydescription/observer</class>
      <method>ebayQtyUpdate</method>
      <type>singleton</type>
      </me_createebaydescription>
      </observers>
      </catalog_product_save_after>
      </events>


      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));

      Mage::getSingleton('catalog/product_action')
      ->updateAttributes($ID, $UpdateData, 0);






      share|improve this answer





























        0














        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:



         <events>
        <catalog_product_save_before>
        <observers>
        <me_createebaydescription>
        <class>me_createebaydescription/observer</class>
        <method>ebayDescriptionUpdate</method>
        <type>singleton</type>
        </me_createebaydescription>
        </observers>
        </catalog_product_save_before>
        <catalog_product_save_after>
        <observers>
        <me_createebaydescription>
        <class>me_createebaydescription/observer</class>
        <method>ebayQtyUpdate</method>
        <type>singleton</type>
        </me_createebaydescription>
        </observers>
        </catalog_product_save_after>
        </events>


        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));

        Mage::getSingleton('catalog/product_action')
        ->updateAttributes($ID, $UpdateData, 0);






        share|improve this answer



























          0












          0








          0







          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:



           <events>
          <catalog_product_save_before>
          <observers>
          <me_createebaydescription>
          <class>me_createebaydescription/observer</class>
          <method>ebayDescriptionUpdate</method>
          <type>singleton</type>
          </me_createebaydescription>
          </observers>
          </catalog_product_save_before>
          <catalog_product_save_after>
          <observers>
          <me_createebaydescription>
          <class>me_createebaydescription/observer</class>
          <method>ebayQtyUpdate</method>
          <type>singleton</type>
          </me_createebaydescription>
          </observers>
          </catalog_product_save_after>
          </events>


          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));

          Mage::getSingleton('catalog/product_action')
          ->updateAttributes($ID, $UpdateData, 0);






          share|improve this answer















          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:



           <events>
          <catalog_product_save_before>
          <observers>
          <me_createebaydescription>
          <class>me_createebaydescription/observer</class>
          <method>ebayDescriptionUpdate</method>
          <type>singleton</type>
          </me_createebaydescription>
          </observers>
          </catalog_product_save_before>
          <catalog_product_save_after>
          <observers>
          <me_createebaydescription>
          <class>me_createebaydescription/observer</class>
          <method>ebayQtyUpdate</method>
          <type>singleton</type>
          </me_createebaydescription>
          </observers>
          </catalog_product_save_after>
          </events>


          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));

          Mage::getSingleton('catalog/product_action')
          ->updateAttributes($ID, $UpdateData, 0);







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 19 '16 at 21:25

























          answered Apr 19 '16 at 19:46









          lv2flylv2fly

          6613 bronze badges




          6613 bronze badges























              0














              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->setYourAttribute($NewValue);
              or
              $product->setData('YourAttribute', $NewValue);





              share|improve this answer



























                0














                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->setYourAttribute($NewValue);
                or
                $product->setData('YourAttribute', $NewValue);





                share|improve this answer

























                  0












                  0








                  0







                  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->setYourAttribute($NewValue);
                  or
                  $product->setData('YourAttribute', $NewValue);





                  share|improve this answer













                  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->setYourAttribute($NewValue);
                  or
                  $product->setData('YourAttribute', $NewValue);






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 29 '16 at 18:40









                  lv2flylv2fly

                  6613 bronze badges




                  6613 bronze badges



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f111425%2faccessing-data-in-catalog-product-save-before-observer%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                      Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                      Get RecordId in LWC From Community PageLWC Community recordId undefinedhow to get Personal Access Token from my integrated application LWC. I am using js onlylwc quick action from Opportunity page(aura:component) and not getting @api recordIdLWC Community recordId undefinedLWC - How to get label name of buttonsLWC: Add a region in custom community themeVisual force page redirection from lightning communityLWC NavigationMixin does not work in CommunityInvoking LWC component from a plain URL - Read URL Parameter inside LWCLWC download PDF fileLWC Get Pick-list Field Values