update_list($id);
$productlist = ATKPCache::get_cache_by_id($id);
}
$preferlocalproductinfo = ATKPTools::get_post_setting( $id, ATKP_LIST_POSTTYPE.'_preferlocalproduct');
$outputprds = array();
if($productlist != null) {
if($randomsort)
shuffle($productlist);
$counter = 0;
foreach ($productlist as $product) {
try {
$type = $product['type'];
$value = $product['value'];
if($value == '')
continue;
if($counter >= $limit)
break;
$counter = $counter +1;
switch($type) {
case 'product':
//nur nach lokalen produkten suchen wenn in der
if($preferlocalproductinfo)
{
$prdfound = atkp_product::loadbyasin($value->asin);
if($prdfound != null)
$value = $prdfound;
}
break;
case 'productid':
if(get_post_status($value) == 'publish' || get_post_status($value) == 'draft')
$value = atkp_product::load($value);
else
$value = null;
break;
}
if($value != null)
array_push($outputprds, $value);
} catch(Exception $e) {
//TODO: 'Exception: ', $e->getMessage(), "\n";
}
}
}
$resultValue = $templatehelper->createOutput($outputprds, $content, $template, $containercss, $elementcss, $buttontype, $id, $hidedisclaimer, 0, $tracking_id);
return $resultValue;
}
public function get_filterlist_output($template = 'wide', $content='', $buttontype = 'notset', $elementcss = '', $containercss = '', $items_per_page = 10, $hidedisclaimer = false, $tracking_id ='') {
$template = apply_filters('atkp_modify_template', $template);
require_once ATKP_PLUGIN_DIR.'/includes/atkp_product.php';
require_once ATKP_PLUGIN_DIR.'/includes/atkp_product_image.php';
require_once ATKP_PLUGIN_DIR.'/includes/atkp_product_offer.php';
require_once ATKP_PLUGIN_DIR.'/includes/helper/atkp_template_helper.php';
$templatehelper = new atkp_template_helper();
$page = get_query_var( 'page' ) ? intval(get_query_var( 'page' )) : 1;
$outputprds = array();
$pages = 1;
global $post;
$args = array(
'post_type' => ATKP_PRODUCT_POSTTYPE,
'posts_per_page' => $items_per_page,
'post_status' => array('publish', 'draft'),
'paged' => $page,
);
$myfilters = $templatehelper->createFilterPlaceholderArray('');
foreach($myfilters as $fieldname => $control) {
if(ATKPTools::exists_get_parameter($fieldname) && ATKPTools::get_get_parameter($fieldname, 'string') !='') {
}
}
$filtervalues = array();
foreach($_GET as $key => $value) {
$fieldvalue =ATKPTools::get_get_parameter($key, 'string');
$fieldname = $key;
if($fieldvalue !='') {
if($fieldname == 'search') {
$filtervalues['search'] = ATKPTools::get_get_parameter($key, 'string');
} else if($fieldname == 'rating') {
$filtervalues['rating'] = ATKPTools::get_get_parameter($key, 'int');
} else if($fieldname == 'price') {
$filtervalues['rating'] = ATKPTools::get_get_parameter($key, 'double');
} else if(ATKPTools::startsWith($key, 'productid')) {
$filtervalues[$fieldname] = ATKPTools::get_get_parameter($key, 'int');
} else if(ATKPTools::startsWith($key, 'customfield_')) {
} else if(ATKPTools::startsWith($key, 'customtaxonomy_')) {
} else
throw new exception('uknown field: '.$fieldname);
echo $fieldname . ': '. ATKPTools::get_get_parameter($fieldname, 'string') . '
';
}
}
$the_query = new WP_Query($args);
$nextpagelink ='';
$lastpagelink ='';
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
try {
$product = atkp_product::load($the_query->post->ID);
array_push($outputprds, $product);
} catch(Exception $e) {
//TODO: 'Exception: ', $e->getMessage(), "\n";
}
}
$pages = $the_query->max_num_pages;
/* Restore original Post Data */
wp_reset_postdata();
$resultValue = $templatehelper->createOutput($outputprds, $content, $template, $containercss, $elementcss, $buttontype, '', $hidedisclaimer, 0, $tracking_id);
$nextpagelink = get_permalink($post->ID); ;
$lastpagelink = get_permalink($post->ID); ;
$paging = '';
if($pages > 1) {
if($page < $pages) {
$paging .= 'next page';
}
$paging .= $page;
if($page > 1 && $page <= $pages) {
$paging .= 'last page';
}
}
$resultValue .= $paging;
}
return $resultValue;
}
public function get_product_output($id, $template = 'box', $content='', $buttontype = 'notset', $field, $link = false, $elementcss = '', $containercss = '', $hidedisclaimer = false, $tracking_id='') {
$template = apply_filters('atkp_modify_template', $template);
$template = apply_filters('atkp_modify_template_product', $template, $id, $content);
$resultValue ='';
require_once ATKP_PLUGIN_DIR.'/includes/atkp_product.php';
require_once ATKP_PLUGIN_DIR.'/includes/atkp_product_image.php';
require_once ATKP_PLUGIN_DIR.'/includes/atkp_product_offer.php';
if(get_post_status($id) != 'publish' && get_post_status($id) != 'draft')
return '';
$prd = atkp_product::load($id);
require_once ATKP_PLUGIN_DIR.'/includes/helper/atkp_template_helper.php';
$templatehelper = new atkp_template_helper();
if($field != '') {
$placeholders = ATKPCache::get_cache_by_id('placeholders_'. $id);
if($placeholders == null) {
$placeholders = $templatehelper->createPlaceholderArray($prd, 1, $containercss, $elementcss, $content, $buttontype, '','', $tracking_id);
ATKPCache::set_cache_by_id('placeholders_'. $id, $placeholders, 120);
}
foreach(array_keys($placeholders) as $key)
if($key == $field){
$resultValue = $placeholders[$key];
break;
}
if($containercss != '') {
$resultValue = '