Php Can';t设置新产品';从prestashop模块中选择数量和供应商

Php Can';t设置新产品';从prestashop模块中选择数量和供应商,php,prestashop,prestashop-1.6,Php,Prestashop,Prestashop 1.6,我编写了一个prestashop模块,它允许添加新产品。我有一个问题:在表“ps_products”中,它成功地保存了所有信息,但当我在管理面板catalog->products中打开添加的产品时,数量为0,并且没有选择供应商。这是我的密码: $message = ''; $erori = false; $arr = array(); $feats = array(); $imgs = array(); $arr['nume_produs'] = Tools::getValue('pr_n

我编写了一个prestashop模块,它允许添加新产品。我有一个问题:在表“ps_products”中,它成功地保存了所有信息,但当我在管理面板catalog->products中打开添加的产品时,数量为0,并且没有选择供应商。这是我的密码:

 $message = '';
$erori = false;
$arr = array();
$feats = array();
$imgs = array();


$arr['nume_produs'] = Tools::getValue('pr_name');
$arr['pr_pret_ach'] = Tools::getValue('pr_pret_ach'); 

$arr['pr_pret_angro'] = Tools::getValue('pr_pret_angro'); 

$arr['pr_supp'] = explode("=", Tools::getValue('pr_supp'));


$arr['pr_refer'] = Tools::getValue('pr_refer'); 
$arr['pr_manuf'] = Tools::getValue('pr_manuf'); 
$arr['pr_short_desc'] = Tools::getValue('pr_short_desc');

$arr['proxy'] = Tools::getValue('proxy'); 
$res = yamarketsync::update_proxy($arr['proxy']);


$arr['categorii'] = Tools::getValue('categoryBox'); 

if(Tools::getValue('active') == 1)   $arr['activ'] = true; 
else  $arr['activ'] = false;


$product = new Product(); 
    $langId = (int) (Configuration::get('PS_LANG_DEFAULT'));

    $name_ro = Tools::getValue('pr_name_ro');
    if(Tools::getValue('pr_name_ru') != '')$name_ru = Tools::getValue('pr_name_ru'); else $name_ru = $name_ro;
    if(Tools::getValue('pr_name_en') != '')$name_en = Tools::getValue('pr_name_en'); else $name_en = $name_ro;
    if(Tools::getValue('pr_name_uk') != '')$name_uk = Tools::getValue('pr_name_uk'); else $name_uk = $name_ro;

    $s_desc_ro = Tools::getValue('pr_short_desc_ro');
    if(Tools::getValue('pr_short_desc_ru') != '')$s_desc_ru = Tools::getValue('pr_short_desc_ru'); else $s_desc_ru = $s_desc_ro;
    if(Tools::getValue('pr_short_desc_en') != '')$s_desc_en = Tools::getValue('pr_short_desc_en'); else $s_desc_en = $s_desc_ro;
    if(Tools::getValue('pr_short_desc_uk') != '')$s_desc_uk = Tools::getValue('pr_short_desc_uk'); else $s_desc_uk = $s_desc_ro;

    $desc_ro = Tools::getValue('pr_desc_ro');
    if(Tools::getValue('pr_desc_ru') != '')$desc_ru = Tools::getValue('pr_desc_ru'); else $desc_ru = $desc_ro;
    if(Tools::getValue('pr_desc_en') != '')$desc_en = Tools::getValue('pr_desc_en'); else $desc_en = $desc_ro;
    if(Tools::getValue('pr_desc_uk') != '')$desc_uk = Tools::getValue('pr_desc_uk'); else $desc_uk = $desc_ro;

    $product->id_supplier =  $arr['pr_supp'][0];
    $product->supplier_name = $arr['pr_supp'][1];
    $product->id_manufacturer = Tools::getValue('pr_manuf');
    $product->description_short = array('4' => $s_desc_ro, '3' => $s_desc_ru, '1' => $s_desc_en,'5' => $s_desc_uk);
    $product->description = array('4' => $desc_ro, '3' => $desc_ru, '1' => $desc_en,'5' => $desc_uk);
    $product->quantity = Tools::getValue('pr_cant');

    $product->name = array('4' => $name_ro, '3' => $name_ru, '1' => $name_en,'5' => $name_uk);
    $product->price = Tools::getValue('pr_pret_ach');
    $product->wholesale_price = Tools::getValue('pr_pret_angro');
    $product->active = $arr['activ'];


    $product->id_category_default= $arr['categorii'][0];
    $product->category=$arr['categorii'];
    $product->reference = $arr['pr_refer'];
    $product->link_rewrite = array('4' => Tools::link_rewrite($name_ro),'3' => Tools::link_rewrite($name_ru),'1' => Tools::link_rewrite($name_en),'5' => Tools::link_rewrite($name_uk));



    $res = $product->add();
    if(!$res) $erori = true;

    //adaugam features
    $num = Tools::getValue('feat_num');
    $i=0;

    $id_product = (int)$product->id;


    while($i <= $num){
        if( Tools::getValue('feat_name-'.$i) !='' && Tools::getValue('feat_value-'.$i) != ''){

              if(!yamarketsync::exista_deja_asociere(Tools::getValue('ya_feature_name-'.$i), Tools::getValue('feat_name-'.$i) )){ 
                     yamarketsync::save_asociere(Tools::getValue('ya_feature_name-'.$i), Tools::getValue('feat_name-'.$i) );     
                }
              $rezultat =  Product::addFeatureProductImport($id_product, Tools::getValue('feat_name-'.$i), Tools::getValue('feat_value-'.$i));
              if(!$rezultat) $erori = true;
        }
    $feats[$i]['name'] = Tools::getValue('feat_name-'.$i);
    $feats[$i]['value'] = Tools::getValue('feat_value-'.$i);
    $i++;
}


     $i=0;
     $num = Tools::getValue('img_num');

while($i < $num){
    $imgs[$i] = Tools::getValue('image-'.$i);

    $img = new Image();
    $img->id_product = $product->id;
    $img->add();
   $rezultat = AdminImportController::copyImg2($product->id, $img->id, $imgs[$i]);
    if(!$rezultat) $erori = true;
    $i++;
}






   if($erori == true) return $this->displayError($this->l('Au aparut erori in timpul salvarii.'));
    else return $this->displayConfirmation($this->l('Modificarile au fost salvate.'));
$message='';
$erori=假;
$arr=array();
$feats=array();
$imgs=array();
$arr['nume_produs']=Tools::getValue('pr_name');
$arr['pr_pret_ach']=Tools::getValue('pr_pret_ach');
$arr['pr_pret_angro']=Tools::getValue('pr_pret_angro');
$arr['pr_supp']=explode(“=”,Tools::getValue('pr_supp');
$arr['pr_refere']=Tools::getValue('pr_refere');
$arr['pr_manuf']=Tools::getValue('pr_manuf');
$arr['pr_short_desc']=Tools::getValue('pr_short_desc');
$arr['proxy']=Tools::getValue('proxy');
$res=yamarketsync::update_proxy($arr['proxy']);
$arr['categori']=Tools::getValue('categoryBox');
如果(Tools::getValue('active')==1)$arr['activ']=true;
else$arr['activ']=false;
$product=新产品();
$langId=(int)(配置::get('PS_LANG_DEFAULT');
$name_ro=Tools::getValue('pr_name_ro');
如果(Tools::getValue('pr_name_ru')!=“”)$name_ru=Tools::getValue('pr_name_ru');else$name\u ru=$name\u ro;
如果(Tools::getValue('pr_name_en')!=“”)$name_en=Tools::getValue('pr_name_en');else$name\u en=$name\u ro;
如果(Tools::getValue('pr_name_uk')!=“”)$name_uk=Tools::getValue('pr_name_uk');else$name_uk=$name_ro;
$s_desc_ro=Tools::getValue('pr_short_desc_ro');
如果(Tools::getValue('pr_short_desc_ru')!=“”)$s_desc_ru=Tools::getValue('pr_short_desc_ru');else$s_desc_ru=$s_desc_ro;
如果(Tools::getValue('pr_short_desc_en')!=“”)$s_desc_en=Tools::getValue('pr_short_desc_en');else$s_desc_en=$s_desc_ro;
如果(Tools::getValue('pr_short_desc_uk')!=“”)$s_desc_uk=Tools::getValue('pr_short_desc_uk');其他$s_desc_uk=$s_desc_ro;
$desc_ro=Tools::getValue('pr_desc_ro');
如果(Tools::getValue('pr_desc_ru')!=“”)$desc_ru=Tools::getValue('pr_desc_ru');else$desc_ru=$desc_ro;
如果(Tools::getValue('pr_desc_en')!=“”)$desc_en=Tools::getValue('pr_desc_en');else$desc_en=$desc_ro;
如果(Tools::getValue('pr_desc_uk')!=“”)$desc_uk=Tools::getValue('pr_desc_uk');else$desc_uk=$desc_ro;
$product->id_supplier=$arr['pr_supp'][0];
$product->supplier_name=$arr['pr_supp'][1];
$product->id_manufacturer=Tools::getValue('pr_manuf');
$product->description\u short=array('4'=>$s\u desc\u ro,'3'=>s\u desc\u ru,'1'=>s\u desc\u en,'5'=>s\u desc\u uk);
$product->description=array('4'=>$desc\u ro,'3'=>$desc\u ru,'1'=>$desc\u en,'5'=>$desc\u uk);
$product->QUOTE=Tools::getValue('pr_cant');
$product->name=array('4'=>$name\u ro,'3'=>$name\u ru,'1'=>$name\u en,'5'=>$name\u uk);
$product->price=Tools::getValue('pr_pret_ach');
$product->批发价格=工具::getValue('pr_pret_angro');
$product->active=$arr['activ'];
$product->id_category_default=$arr['categorii'][0];
$product->category=$arr['categorii'];
$product->reference=$arr['pr_reference'];
$product->link\u rewrite=array('4'=>Tools::link\u rewrite($name\u ro),'3'=>Tools::link\u rewrite($name\u ru),'1'=>Tools::link\u rewrite($name\u en),'5'=>Tools::link\u rewrite($name\u uk));
$res=$product->add();
如果(!$res)$erori=true;
//阿杜加姆特征
$num=Tools::getValue('feat_num');
$i=0;
$id_product=(int)$product->id;
而($i id\u product=$product->id;
$img->add();
$rezultat=AdminImportController::copyImg2($product->id,$img->id,$imgs[$i]);
如果(!$rezultat)$erori=true;
$i++;
}
if($erori==true)返回$this->displayError($this->l('Au aparut erori in timpul salvarii');
否则返回$this->displayConfirmation($this->l('modificalile au fost salvate');

我的朋友,添加此项以完成更新产品数量:

StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, $this->context->shop->id)