ard54 Posted August 23, 2010 Share Posted August 23, 2010 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 Link to comment Share on other sites More sharing options...
rocky Posted August 23, 2010 Share Posted August 23, 2010 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. Link to comment Share on other sites More sharing options...
ard54 Posted August 23, 2010 Author Share Posted August 23, 2010 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now