Jump to content

New Product classes code


ard54
 Share

Recommended Posts

Hi,

Can anyone tell me where the PHP code is that deals with adding a new product?

If I do a MySQL general log when adding a new product via admin panel it will record all the INSERT operations so I know what happened, but I've searched for this in the classes directory so I can see the actual code called that generates the db calls and can only find product_lang etc table operations but I can't see the product table INSERTs anywhere.

I want to see what actual code is called rather than try to work it out with MySQL logs.

Thanks

Share this post


Link to post
Share on other sites

I think it uses the generic code in the ObjectModel.php class that inserts the product data. It is the following code in the add() function:

/* Database insertion */
if ($nullValues)
   $result = Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_.$this->table, $this->getFields(), 'INSERT');
else
   $result = Db::getInstance()->autoExecute(_DB_PREFIX_.$this->table, $this->getFields(), 'INSERT');



When adding products, _DB_PREFIX_.$this->table evaluates to ps_product, $this->getFields() adds the data for VALUES, and 'INSERT' adds INSERT INTO to the front of the query.

Share this post


Link to post
Share on other sites

Thanks Rocky,

Yes, it's part of the ObjectModel that the Product class inherits from. It's ok when you get your head around it! I was looking to develop an api that can be called and invokes class code to do things instead of poking things directly into the db tables and it started to look cryptic.

Thanks again

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More