Php 通过一个模块预售具有功能和图像的新产品

Php 通过一个模块预售具有功能和图像的新产品,php,prestashop,Php,Prestashop,除功能和图像外,已成功添加产品信息。这是我的密码: $product = new Product(); $image = new Image(); $langId = (int) (Configuration::get('PS_LANG_DEFAULT')); $name = Tools::getValue('pr_name'); $product->id_supplier = $arr['pr_supp'][0]; $product->i

除功能和图像外,已成功添加产品信息。这是我的密码:

 $product = new Product();
    $image = new Image();
    $langId = (int) (Configuration::get('PS_LANG_DEFAULT'));
    $name = Tools::getValue('pr_name');
    $product->id_supplier =  $arr['pr_supp'][0];
    $product->id_manufacturer = Tools::getValue('pr_manuf');
    $product->description_short = Tools::getValue('pr_short_desc');
    $product->description = Tools::getValue('pr_desc');
    $product->quantity = Tools::getValue('pr_cant');

    $product->name = array($langId => $name);
    $product->price = Tools::getValue('pr_pret_ach');
    $product->wholesale_price = Tools::getValue('pr_pret_angro');
    $product->active = false;
    //$product->is_virtual = true;
   // $product->cache_has_attachments = true;
    $product->id_category_default= $arr['categorii'][0];
    $product->reference = $this->context->cookie->id_customer;
    $product->link_rewrite = array($langId => Tools::link_rewrite($name));

    //some test values
    $product->product_features = array(
        'id' => '123',
        'id_feature_value' => '111'
    );

    $product->add();



    //trying to save images (got just images src from another server)
    $image->id_product = (int)$product->id;

     $i=0;

while($i <= $num){
    $imgs[$i] = Tools::getValue('image-'.$i);
     AdminImportController::copyImg2($product->id, $imgs[$i], 'products');
     $i++;
}
另一个问题是如何保存功能。以下是
$product
对象的
print\r()

 ....
[category] => 
[webserviceParameters:protected] => Array
    (
        [objectMethods] => Array
            (
                [add] => addWs
                [update] => updateWs
            )

        [objectNodeNames] => products
        [fields] => Array
            (
                [id_manufacturer] => Array
                    (
                        [xlink_resource] => manufacturers
                    )




                [id_default_image] => Array
                    (
                        [getter] => getCoverWs
                        [setter] => setCoverWs
                        [xlink_resource] => Array
                            (
                                [resourceName] => images
                                [subResourceName] => products
                            )

                    )

                [id_default_combination] => Array
                    (
                        [getter] => getWsDefaultCombination
                        [setter] => setWsDefaultCombination
                        [xlink_resource] => Array
                            (
                                [resourceName] => combinations
                            )

                    )

                [id_tax_rules_group] => Array
                    (
                        [xlink_resource] => Array
                            (
                                [resourceName] => tax_rule_groups
                            )

                    )


            )

        [associations] => Array
            (
                [categories] => Array
                    (
                        [resource] => category
                        [fields] => Array
                            (
                                [id] => Array
                                    (
                                        [required] => 1
                                    )

                            )

                    )

                [images] => Array
                    (
                        [resource] => image
                        [fields] => Array
                            (
                                [id] => Array
                                    (
                                    )

                            )

                    )

               //here may be the features, but i don't know how to put it there
                [product_features] => Array
                    (
                        [resource] => product_feature
                        [fields] => Array
                            (
                                [id] => Array
                                    (
                                        [required] => 1
                                    )

                                [custom] => Array
                                    (
                                        [required] => 
                                    )

                                [id_feature_value] => Array
                                    (
                                        [required] => 1
                                        [xlink_resource] => product_feature_values
                                    )

                            )

                    )
谈论图像:

首先为每个人做一个循环,以重复此操作:

$img = new Image();
$img->id_product = $product->id;
$img->add();
你可以在这里做得更多。语言等等。。在此更新之后:

$this->copyImg($product->id, $img->id, $yourImagePath)

你是在提供信息还是在问问题?我说不出来,因为我看到的只是一堆没有任何解释的代码。请看一看,了解一些关于提出一个好问题的想法,以便从社区获得适当的帮助;)我问的是如何在添加产品时添加图像,以及如何向产品对象添加一些功能(需要类似:$product->选择product features属性=$array with features)。
$this->copyImg($product->id, $img->id, $yourImagePath)