Jump to content

Produit invisible sur le FrontOffice mais visible en backoffice


agarmur

Recommended Posts

Bonjour, voici mon problème, je créer un produit grâce à un module que je développe, le problème que je rencontre, c'est que le produit est bien créer je peux le voir en backoffice mais sur ma boutique impossible de le voir ! Le seul moyen que je puisse l'afficher c'est de cliquer sur le bouton Enregistrer 

voici mon code :

        $xml = simplexml_load_file('php://input');
        $product = new Product($xml->id);
        foreach ($xml->categories->category as $empl) {
            $sql = "SELECT `id_category` FROM `"._DB_PREFIX_."category` WHERE `id_multisite` = '$empl->IDMultisite'";
            $categories = Db::getInstance()->executeS($sql);
            foreach ($categories as $categorie){
                $product->category = $categorie['id_category'];
                $product->id_category_default = (int)$categorie['id_category'];
            }
        }
        $product->name = (string)$xml->name;
        $product->price = (int)$xml->price;
        $id_TaxRulesGroup = TaxRulesGroup::getIdByName("TVA FR $xml->tax%");
        if (!$id_TaxRulesGroup) {
            $taxrulegroup = new TaxRulesGroupCore();
            $taxrulegroup->name = "TVA FR $xml->tax%";
            $taxrulegroup->active = true;
            $taxrulegroup->save();
            $tax = new TaxCore();
            foreach (Language::getLanguages(false) as $lang) {
                $tax->name[$lang['id_lang']] = "TVA FR $xml->tax%";
            }
            $tax->rate = $xml->tax;
            $tax->active = true;
            $tax->save();
            $taxrule = new TaxRuleCore();
            $id_TaxRulesGroup = TaxRulesGroup::getIdByName("TVA FR $xml->tax%");
            $taxrule->id_tax_rules_group = $id_TaxRulesGroup;
            $taxrule->id_tax = $tax->id;
            $taxrule->id_country = Tools::getCountry();
            $taxrule->save();
            $product->id_tax_rules_group = $id_TaxRulesGroup;
        } else {
            $product->id_tax_rules_group = $id_TaxRulesGroup;
        }
        $product->unit_price = (int)$xml->unit_price;
        $product->ecotax = (int)$xml->ecotax;
        $product->ean13 = (string)$xml->ean13;
        $description = $xml->description->asXML(); //Description
        $short_description = $xml->description_short->asXML(); // Description courte
        $product->description = html_entity_decode($description);//Description
        $product->description_short = html_entity_decode($short_description);// Description courte
        $product->reference = $xml->reference;
        $product->weight = $xml->weight;
        $product->height = $xml->height;
        $product->depth = $xml->depth;
        $product->meta_title = $xml->metaTitle;
        $product->meta_description = $xml->metaDescription;
        $product->indexed = 1;
        $product->active = true;
        $product->save();
        foreach ($xml->Images->image as $img) {
            $image = new Image();
            $image->id_product = (int)$product->id;
            $image->position = (int)$img->OrdreAffichage;
            if ($img->ParDefaut == "0") {
                $image->cover = false;
            } else {
                $image->cover = true;
            }
            $image->image_format = 'jpg';
            $image->save();
            $this->copyImg((int)$product->id, (int)$image->id, $img->img, 'products', false);
            $sql = "UPDATE `"._DB_PREFIX_."image` SET `id_multisite`='$img->idMultisite' WHERE `id_image` = $image->id";
            DB::getInstance()->execute($sql);
        }

En espèrent que cela aidera !

Merci ! 

Link to comment
Share on other sites

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...