JasonWang Posted February 24, 2014 Share Posted February 24, 2014 (edited) I change the value of id_category_default in table "product" for each product. like id_product id_category_default 1 20 But when I try to new a Product. $product = new Product(1,false,1); the val $product->id_category_default is not 20, but the old number 3. In DB, id_category_default is 20, when I new this Product, $product->id_category_default is 3. OMG! I dont know what to do now...Then I followed the Product::__construct() into this step: public function nextRow($result = false) { if (!$result) $result = $this->result; return $result->fetch(PDO::FETCH_ASSOC); } $result is a PDOStatement, which has a property "queryString", whose value is "SELECT *FROM `oc_product` a LEFT JOIN `oc_product_lang` `b` ON a.id_product = b.id_product AND b.id_lang = 1 LEFT JOIN `oc_product_shop` `c` ON a.id_product = c.id_product AND c.id_shop = 1 WHERE (a.id_product = 9) AND (b.id_shop = 1) LIMIT 1" I ran this sql in the Navicat, the id_category_default in the result is 20. But when the program went into next step. The method above returned a result whose "id_category_default" is 3. Could anyone tell me what's happend? What's wrong with PDO? PS However, if I modify the "default category" in the backoffice, then the val $product->id_category_default is right. What's the difference between directly changing the number in DB and in back office? How can I bulkly change the id_category_default? PS2 I found the list under the Product Tab is showing a column named "Category". Even I change the "id_category_default" value in the DB, the culumn's value doesnt change in the Back Office. All I want to do is to bulkly change the products' default category. Edited February 24, 2014 by JasonWang (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted February 24, 2014 Share Posted February 24, 2014 Try changing it in ps_product_shop too Link to comment Share on other sites More sharing options...
JasonWang Posted February 24, 2014 Author Share Posted February 24, 2014 Try changing it in ps_product_shop too Thank you! you are right. What a terrible disign. Store one data twice. Link to comment Share on other sites More sharing options...
NemoPS Posted February 24, 2014 Share Posted February 24, 2014 Indeed. I guess the former one has been left for retro-compatibility though Link to comment Share on other sites More sharing options...
JasonWang Posted March 4, 2014 Author Share Posted March 4, 2014 Indeed. I guess the former one has been left for retro-compatibility though Yes. It is also probably for "multi-shop". Link to comment Share on other sites More sharing options...
Recommended Posts