public function getJSON() { $itemid = $this->itemid; $apiuser = $GLOBALS["DB"]->executeQuery("SELECT username, apikey FROM xplugin_newsletter2go_keys", 1); // Query Artikel [tartikel] // Kann man irgendwie auch den Artikel als Objekt direkt so laden? $query = "SELECT `kArtikel` FROM `tartikel` WHERE `cArtNr` = '{$itemid}'"; $produkt = $GLOBALS["DB"]->executeQuery($query, 9); if (empty($produkt)) { return $this->getError(200); } $kArtikel = $produkt[0]['kArtikel']; $artikel = new Artikel(); $artikel->fuelleArtikel($kArtikel, false); $json = array("itemID" => $artikel->cArtNr, "name" => utf8_encode($artikel->cName), "url" => gibShopURL(), "link" => '/' . $artikel->cSeo, "short_description" => utf8_encode($artikel->cKurzBeschreibung), "description" => utf8_encode($artikel->cBeschreibung), "images" => array()); // Bilder zum Artikel $artikel->holBilder(); foreach ($artikel->Bilder as $bild) { $json['images'][] = gibShopURL() . '/' . $bild->cPfadNormal; } $json['price'] = $artikel->gibPreis(1, false); $json['taxes'] = (double) gibUst($artikel->kSteuerklasse) / 100; return json_encode($json); }
/** * Get product informations. * * @return mixed Product info. */ public function getProductInfo() { // Article number $identifier = filter_input(INPUT_POST, 'identifier'); if ($identifier === null) { self::sendError('Indentifier not found.'); } $query = 'SELECT kArtikel FROM ' . self::PRODUCTS_TABLE . " WHERE cArtNr = '{$identifier}'"; $productInfoFromDb = $GLOBALS["DB"]->executeQuery($query, 9); if (empty($productInfoFromDb)) { self::sendError(sprintf('Product with article number %d has not been found.', $identifier)); } $language = filter_input(INPUT_POST, 'language'); $productInfo = $productInfoFromDb[0]['kArtikel']; $product = new Artikel(); $product->fuelleArtikel($productInfo, false, 0, $language); if ($product->cArtNr != $identifier) { self::sendError('Product not found in this language!'); } $productPrice = $product->gibPreis(1, false); $productTax = (double) gibUst($product->kSteuerklasse) / 100; $productToReturn = array(); foreach (self::getProductAttributeDefinitions() as $attributeDefinition) { $attributeName = $attributeDefinition['id']; // If attribute is not requested, don't add it. if (self::isProductAttributeRequested($attributeName) === false) { continue; } if ($attributeName === 'oldPrice' || $attributeName === 'newPrice') { $productToReturn[$attributeName] = isset($productPrice) ? round($productPrice * ($productTax + 1), 2) : false; continue; } if ($attributeName === 'oldPriceNet' || $attributeName === 'newPriceNet') { $productToReturn[$attributeName] = isset($productPrice) ? round($productPrice, 2) : false; continue; } if ($attributeName === 'url') { $productToReturn[$attributeName] = gibShopURL(); continue; } if ($attributeName === 'images') { $product->holBilder(); foreach ($product->Bilder as $bild) { $productToReturn[$attributeName][] = gibShopURL() . '/' . $bild->cPfadNormal; } continue; } if ($attributeName === 'fMwSt') { $productToReturn[$attributeName] = $productTax; continue; } $productToReturn[$attributeName] = isset($product->{$attributeName}) ? $product->{$attributeName} : ''; } return $productToReturn; }