bantumi Posted April 12, 2015 Share Posted April 12, 2015 Hi,guys! I am using class Product to import products in my website, but i need some help with this, as long as I am pretty new to Prestashop. The problem is that i can't find how to set value to custom feature of the products. For example: I have custom feature called "phone" how can I set value to this feature using class Product?Here is a part of my code: $product->name = array((int)Configuration::get('PS_LANG_DEFAULT') => "$title");; $product->link_rewrite = array((int)Configuration::get('PS_LANG_DEFAULT') => "$title_rewrite"); $product->redirect_type = '404'; $product->price = $price; $product->quantity = 1; $product->minimal_quantity = 1; $product->show_price = 1; $product->on_sale = 0; $product->online_only = 1; $product->meta_keywords =$keywords; $product->is_virtual=1; $product->id_category_default = 2; $product->add(); $product->addToCategories(array(0=>2,1=>$cat_info[$cat_rewrite])); Thanks in advance! Link to comment Share on other sites More sharing options...
fred-vinapresta Posted April 13, 2015 Share Posted April 13, 2015 Hi, you can find these methods in Product Class public function addFeaturesCustomToDB($id_value, $lang, $cust) {...} public function addFeaturesToDB($id_feature, $id_value, $cust = 0) {...} Link to comment Share on other sites More sharing options...
bantumi Posted April 13, 2015 Author Share Posted April 13, 2015 What If I have features with values which are not pre-defined? Can you give me example? Link to comment Share on other sites More sharing options...
bantumi Posted April 17, 2015 Author Share Posted April 17, 2015 I solved this writing my own method in the product class. Here it is : public function setFeatureProduct($id_feature,$id_product,$id_feature_value,$value) { $row = array('id_feature' => (int)($id_feature), 'id_product' => (int)$id_product,'id_feature_value'=>(int)$id_feature_value); Db::getInstance()->autoExecute(_DB_PREFIX_.'feature_product', $row, 'INSERT'); $row = array('id_feature_value' => (int)$id_feature_value,'id_feature'=>(int)$id_feature, 'custom' => 1); Db::getInstance()->autoExecute(_DB_PREFIX_.'feature_value', $row, 'INSERT'); $row = array('id_feature_value' => (int)$id_feature_value, 'id_lang' => 6,'value'=>$value); Db::getInstance()->autoExecute(_DB_PREFIX_.'feature_value_lang', $row, 'INSERT'); } Link to comment Share on other sites More sharing options...
jawaid Posted May 24, 2015 Share Posted May 24, 2015 @bantumi where do you call your own method? Can you post your file? 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