mardon Posted November 6, 2014 Share Posted November 6, 2014 I want use own php script fo adding product to shop, i use $product = new Product(); $product->ean13 = 9999999999999; $product->name = array((int)Configuration::get('PS_LANG_DEFAULT') => 'Test importu');; $product->link_rewrite = array((int)Configuration::get('PS_LANG_DEFAULT') => 'test-importu'); $product->id_category = 2; $product->id_category_default = 2; $product->redirect_type = '404'; $product->price = 22; $product->quantity = 1; $product->minimal_quantity = 1; $product->show_price = 1; $product->on_sale = 0; $product->online_only = 1; $product->meta_keywords = 'test'; $product->is_virtual=1; $product->add(); $product->addToCategories(array(2)); $id_product = $product->id; $url = 'http://demo-simpliashop-cz.ecdn.cz/img/mini/4.jpg'; $shops = Shop::getShops(true, null, true); $image = new Image(); $image->id_product = $id_product; $image->position = Image::getHighestPosition($id_product) + 1; $image->cover = true; // or false; if (($image->validateFields(false, true)) === true && ($image->validateFieldsLang(false, true)) === true && $image->add()) { $image->associateTo($shops); if (!AdminImportController::copyImg($id_product, $image->id, $url, 'products', false)) { $image->delete(); } but this produce error: Call to protected method AdminImportControllerCore::copyImg() from context How can i use AdminController in my script Link to comment Share on other sites More sharing options...
theimer Posted November 23, 2014 Share Posted November 23, 2014 the same problem Link to comment Share on other sites More sharing options...
enSysRanjit Posted December 3, 2014 Share Posted December 3, 2014 Hey guys, We can achieve this by overriding AdminImportController class and make copyImage() method as public. Now you can access copyImage() method from anywhere. Hope it will help. Thanks!!!! 1 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