Jump to content

run AdminController from own php script


mardon

Recommended Posts

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

  • 3 weeks later...
  • 2 weeks later...

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
×
×
  • Create New...