| @@ 604-642 (lines=39) @@ | ||
| 601 | *  | 
                                |
| 602 | * @return array  | 
                                |
| 603 | */  | 
                                |
| 604 | public function getFeaturedProducts($credentials, $shop_id)  | 
                                |
| 605 |     { | 
                                |
| 606 | $related_products = array();  | 
                                |
| 607 | ||
| 608 | $this->checkCredentials($credentials);  | 
                                |
| 609 | ||
| 610 | $this->_factoryWebshop($shop_id);  | 
                                |
| 611 | ||
| 612 | $db = MDB2::singleton(DB_DSN);  | 
                                |
| 613 | ||
| 614 |         if (PEAR::isError($db)) { | 
                                |
| 615 | require_once 'XML/RPC2/Exception.php';  | 
                                |
| 616 | throw new XML_RPC2_FaultException($db->getMessage() . $db->getUserInfo(), -1);  | 
                                |
| 617 | }  | 
                                |
| 618 | ||
| 619 | $featured = new Intraface_modules_shop_FeaturedProducts($this->kernel->intranet, $this->webshop->getShop(), $db);  | 
                                |
| 620 | $all = $featured->getAll();  | 
                                |
| 621 | ||
| 622 |         if (false !== ($currency_gateway = $this->getCurrencyGateway())) { | 
                                |
| 623 | $currencies = $currency_gateway->findAllWithExchangeRate();  | 
                                |
| 624 |         } else { | 
                                |
| 625 | $currencies = false;  | 
                                |
| 626 | }  | 
                                |
| 627 | ||
| 628 | $related_products = array();  | 
                                |
| 629 | ||
| 630 |         foreach ($all as $row) { | 
                                |
| 631 | $product_gateway = new Intraface_modules_product_Gateway($this->kernel);  | 
                                |
| 632 |             $product_gateway->getDBQuery()->setFilter('keywords', array($row['keyword_id'])); | 
                                |
| 633 | ||
| 634 | $related_products[] = array(  | 
                                |
| 635 | 'title' => $row['headline'],  | 
                                |
| 636 |                 'products' => $this->cleanUpProductList($product_gateway->getAllProducts('webshop', $currencies)) | 
                                |
| 637 | );  | 
                                |
| 638 | }  | 
                                |
| 639 | ||
| 640 | return $this->prepareResponseData($related_products);  | 
                                |
| 641 | }  | 
                                |
| 642 | ||
| 643 | /**  | 
                                |
| 644 | * Gets product keywords which can be used to sort ones webshop  | 
                                |
| 645 | *  | 
                                |
| @@ 439-477 (lines=39) @@ | ||
| 436 | *  | 
                                |
| 437 | * @return array  | 
                                |
| 438 | */  | 
                                |
| 439 | public function getFeaturedProducts($credentials, $shop_id)  | 
                                |
| 440 |     { | 
                                |
| 441 | $related_products = array();  | 
                                |
| 442 | ||
| 443 | $this->checkCredentials($credentials);  | 
                                |
| 444 | ||
| 445 | $this->_factoryWebshop($shop_id);  | 
                                |
| 446 | ||
| 447 | $db = MDB2::singleton(DB_DSN);  | 
                                |
| 448 | ||
| 449 |         if (PEAR::isError($db)) { | 
                                |
| 450 | require_once 'XML/RPC2/Exception.php';  | 
                                |
| 451 | throw new XML_RPC2_FaultException($db->getMessage() . $db->getUserInfo(), -1);  | 
                                |
| 452 | }  | 
                                |
| 453 | ||
| 454 | $featured = new Intraface_modules_shop_FeaturedProducts($this->kernel->intranet, $this->webshop->getShop(), $db);  | 
                                |
| 455 | $all = $featured->getAll();  | 
                                |
| 456 | ||
| 457 |         if (false !== ($currency_gateway = $this->getCurrencyGateway())) { | 
                                |
| 458 | $currencies = $currency_gateway->findAllWithExchangeRate();  | 
                                |
| 459 |         } else { | 
                                |
| 460 | $currencies = false;  | 
                                |
| 461 | }  | 
                                |
| 462 | ||
| 463 | $related_products = array();  | 
                                |
| 464 | ||
| 465 |         foreach ($all as $row) { | 
                                |
| 466 | $product_gateway = new Intraface_modules_product_Gateway($this->kernel);  | 
                                |
| 467 |             $product_gateway->getDBQuery()->setFilter('keywords', array($row['keyword_id'])); | 
                                |
| 468 | ||
| 469 | $related_products[] = array(  | 
                                |
| 470 | 'title' => $row['headline'],  | 
                                |
| 471 |                 'products' => $this->cleanUpProductList($product_gateway->getAllProducts('webshop', $currencies)) | 
                                |
| 472 | );  | 
                                |
| 473 | }  | 
                                |
| 474 | ||
| 475 | return $this->prepareResponseData($related_products);  | 
                                |
| 476 | }  | 
                                |
| 477 | ||
| 478 | /**  | 
                                |
| 479 | * Gets product keywords which can be used to sort ones webshop  | 
                                |
| 480 | *  | 
                                |