Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8441107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:28:46+00:00 2026-06-10T08:28:46+00:00

have an issue updating magento product from frontend using a module that its function

  • 0

have an issue updating magento product from frontend using a module that its function is for customers to create their own products and have the admin approve before enabled(this part is working).

the problem is when a customer tries to updated their admin approved product (as before approval, product states that newly created product is pending, but they can still update the data/attributes created during the product create function, the same attributes that are not updating using the controller)

first of all i have a controller with the action to update the approved/pending customer product

public function editPostAction() {

        $id = $this->getRequest()->getParam('productid');

        if ( $id !== false ) {

            list($data, $errors) = $this->validatePost();
            if ( !empty($errors) ) {
                foreach ($errors as $message) {
                    $this->_getSession()->addError($message);
                }
                $this->_redirect('customer/products/edit/', array(
                        'id'    => $id
                    ));
            } else {

                $customerId = $this->_getSession()->getCustomer()->getid();
                $product = Mage::getResourceModel('customerpartner/customerpartner_product_collection')
                            ->addAttributeToSelect('*')
                            ->addAttributeToFilter('customer_id', $customerId)
                            ->addAttributeToFilter('entity_id', $id)
                            ->load()
                            ->getFirstItem();

                $product->setName($this->getRequest()->getParam('name'));
                $product->setSku($this->getRequest()->getParam('sku'));
                $product->setDescription($this->getRequest()->getParam('description'));
                $product->setShortDescription($this->getRequest()->getParam('short_description'));
                $product->setPrice($this->getRequest()->getParam('price'));
                $product->setWeight($this->getRequest()->getParam('weight'));
                $product->setStock($this->getRequest()->getParam('stock'));
                $product->save();

                if ( isset($_FILES) && count($_FILES) > 0 ) {
                    foreach($_FILES as $image ) {
                        if ( $image['tmp_name'] != '' ) {
                            if ( ( $error = $this->uploadImage($image, $id) ) !== true ) {
                                $errors[] = $error;
                            }
                        }

                    }
                }

                if ( empty($errors) ) {
                    $this->_getSession()->addSuccess($this->__('Your product was successfully updated'));
                } else {
                    $this->_getSession()->addError('Product info was saved but was imposible to save the image');
                    foreach ($errors as $message) {
                        $this->_getSession()->addError($message);
                    }
                }

                $this->_redirect('customer/products/');

            }
        }
}

as well as a form that on submit is supposed to update the product attributes and images but the page reloads on submit and shows successful saved message but the attributes are not updated and going back to the edit form (for each product created) for that product the values in the update form have the values of the update we just submitted, bet yet the products attributes are not updated in the catalog either (they remain the same values as entered in the create new process)

don’t no if to continue to figure out what is going wrong or just move to either use api or direct sql to get the job done.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:28:47+00:00Added an answer on June 10, 2026 at 8:28 am

    updated to a new action to call in .phtml see below as it seems to be updating the product data as needed, still wanting to improve..
    called in form using /frontendname/editApprovedPost/

    public function editApprovedPostAction() {
    
            $id = $this->getRequest()->getParam('productid');
            $idproduct = $this->getRequest()->getParam('product_id');
    
            if ( $id !== false ) {
    
                list($data, $errors) = $this->validatePost();
                if ( !empty($errors) ) {
                    foreach ($errors as $message) {
                        $this->_getSession()->addError($message);
                    }
                    $this->_redirect('customer/products/edit/', array(
                            'id'    => $id
                        ));
                } else {
    

    – now added more php code to action (in this order) after the } else {…

     require_once 'app/Mage.php';
    

    then add admin store for frontend product updates…

    Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
    

    then get the customer id…

    $customerId = Mage::getSingleton('customer/session')->getCustomerId();
    

    then use the forms product Id to get the Product Id to update…

    $product = Mage::getModel('catalog/product')->load("".$idproduct."");
    

    then use setName() to update/save the attribute value grabbed from the forms input value…

    $product->setName($this->getRequest()->getParam('name'));//use whatever attributes need (only text and text area tested so far)
    

    then save/update product data with…

    $product->save();
    

    then add to run through errors…

     if ( empty($errors) ) {
                        $this->_getSession()->addSuccess($this->__('Your product was successfully updated'));
    
                    } else {
    
                        $this->_getSession()->addError('Product info was saved but was imposible to save the image');
                        foreach ($errors as $message) {
                            $this->_getSession()->addError($message);
                        }
                    }
    
                    $this->_redirect('customer/products/');
    
                }
        }
    }
    

    then with a form to submit in frontend with customer logged in and customer group config

    • custom form only visible to Customer Group 2 (default is Wholesale)

    form below….

    sorry cant paste form to much work to paste the code here, any way using the

    Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
    

    which i have read in some posts is that to update product in frontend you need to be “admin”, which this seems to do just fine. As Noted before, the script was not updating and it was because it is trying to save to a different models data when the data to be updated was an actual product (that has been approved and created using the different models data) and it was updating using

    $product = Mage::getResourceModel('customerpartner/customerpartner_product_collection')
    

    would be good to here anyone else’s comments
    hope this helps someone because was think time to close this build.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here is the issue, I have 6 divs that are using jQuery UI
I have been having an issue with updating a nullable bool value using TryUpdateModel.
I am using multiprocessing module in python2.7 and found to have some issue with
I have an updating issue with Binding in my ComboBox. I have created a
I have an issue where I'm updating millions of rows in my DB, so
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue of alphabetically sorting the contacts picked from the address book
I have an issue with a datagrid inserting/updating rows twice. The datagrid is bound
I have an issue with changing url when i am selecting a value from
I have a strange issue that I'm not too sure on how to fix

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.