Jump to content
  • 0

Produkte die nicht auf Lager sind bestellbar machen funktioniert nicht


xtramen

Question

Hallo Leute,

ich bin am verzweifeln.
Ich füge, in einem selbst erstellten Controller, ein individuelles Produkt ein. Dieses Produkt soll bestellbar sein, unabhängig vom Lagerbestand. Das klappt einfach nicht. Wenn ich allerdings - ohne jegliche Änderung - das Produkt im backend einmal aktualisiere, dann kann ich sofort die Anzahl im Warenkorb beliebig ändern. Anbei mal der wichtigste Teil meines Quellcodes.

 

        $product = new Product();
        $product->ean13 = $ean13;
        $product->reference = $ref;
        $product->name = array((int)($this->context->cookie->id_lang) => $name);
        $product->description = array((int)($this->context->cookie->id_lang) => $text);
        $product->id_category_default = $catDef;
        $product->redirect_type = '301';
        $product->price = number_format($price, 6, '.', '');
        $product->minimal_quantity = 1;
        $product->show_price = 1;
        $product->on_sale = 0;
        $product->online_only = 0;
        $product->meta_description = '';
        $product->link_rewrite = array((int)($this->context->cookie->id_lang) => Tools::str2url($name));
        $product->id_shop_default = (int)$this->context->shop->id;
        $product->id_tax_rules_group = $id_tax_rules_group;
		
        $product->add();
		
        StockAvailable::setQuantity((int)$product->id, 0, (int)$qty, (int)$this->context->shop->id);
        StockAvailable::setProductOutOfStock((int) $product->id, OutOfStockType::OUT_OF_STOCK_AVAILABLE, (int)$this->context->shop->id);

        //Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'product` SET `out_of_stock`= 1 WHERE id_product='.(int)$product->id);
        //Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'stock_available` SET `out_of_stock`= 1 WHERE id_product='.(int)$product->id);

        $this->addFeatures($features, (int)$product->id);

        $this->addImage($imgUrl, (int)$product->id);

        Cache::clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $product->id . '*');

        return $product->id;


Ich finde den Fehler einfach nicht.
Wäre sehr dankbar für einen Hinweis.

Gruß 

Edited by xtramen (see edit history)
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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