Beispiel #1
0
/**
 * Returns info for homepage
 * @param object $response
 */
function fn_twg_set_response_homepage(&$response)
{
    $home_page_content = TwigmoSettings::get('home_page_content');
    if (empty($home_page_content)) {
        $home_page_content = 'random_products';
    }
    if ($home_page_content == 'home_page_blocks' or $home_page_content == 'tw_home_page_blocks') {
        // Use block manager: get blocks
        if ($home_page_content == 'home_page_blocks') {
            $location = 'index.index';
        } else {
            $location = 'twigmo.post';
        }
        $blocks = TwigmoBlock::getBlocksForLocation($location, TwigmoSettings::get('block_types'));
        // Return blocks
        $response->setData($blocks);
    } else {
        $block = array();
        // Random products or category products
        if ($home_page_content == 'random_products') {
            $product_ids = fn_twg_get_random_ids(TWG_RESPONSE_ITEMS_LIMIT, 'product_id', '?:products', db_quote("status = ?s", 'A'));
            $block['title'] = 'random_products';
        } else {
            $product_ids = fn_twg_get_category_product_ids($home_page_content, false) or array();
            $block['title'] = fn_get_category_name($home_page_content);
        }
        list($block['products']) = fn_twg_api_get_products(array('pid' => $product_ids), count($product_ids));
        $block['total_items'] = count($block['products']);
        $response->setData(array($block));
    }
}
Beispiel #2
0
         $condition = implode(' AND ', $conditions);
         $product_ids = fn_twg_get_random_ids($items_qty, 'product_id', $table, $condition);
         if (!empty($product_ids)) {
             $search_params = array('pid' => $product_ids);
             $search_params = array_merge($_REQUEST, $search_params);
             list($result, $search_params) = fn_twg_api_get_products($search_params, $items_qty, $lang_code);
         }
     } elseif ($meta['object'] == 'categories') {
         $condition = '';
         if (!empty($params['category_id'])) {
             $category_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id = ?i", $params['category_id']);
             if (!empty($category_path)) {
                 $condition = "id_path LIKE '{$category_path}/%'";
             }
         }
         $category_ids = fn_twg_get_random_ids($items_qty, 'category_id', '?:categories', $condition);
         if (!empty($category_ids)) {
             $search_params = array('cid' => $category_ids, 'group_by_level' => false);
             $search_params = array_merge($_REQUEST, $search_params);
             $result = fn_twg_api_get_categories($search_params, $lang_code);
         }
     } else {
         $response->addError('ERROR_UNKNOWN_REQUEST', __('unknown_request'));
         $response->returnResponse();
     }
     if (!empty($result)) {
         $response->setResponseList($result);
     }
 } elseif ($meta['action'] == 'apply_for_vendor') {
     if (Registry::get('settings.Suppliers.apply_for_vendor') != 'Y') {
         $response->addError('ERROR_UNKNOWN_REQUEST', __('unknown_request'));