Jump to content
xt:Commerce Community Forum

[SOLVED] cross selling & master / slave


ahuizotl

Recommended Posts

hi,

lt. class im Plugin holt er sich die Daten aus der xt_orders_products über die product-id - da steht aber nix über M/S drin. Man könnte die Tabelle erweitern und schon beim wegschreiben ein Flag setzen, das man dann später abfragt ( sau-aufwändig ) oder die class so erweitern, dass er dort schon die Slaves rausschmeisst.

Was für PHPler.

Grüsse

Ergänzung: Dann werden die Verkäufe von Master-Artikeln aber auch nicht mehr angezeigt ....

Link to comment
Share on other sites

habe die class.auto_cross_sell.php angepasst:

function getAutoCrossSellProductListing($products_id='') {

global $xtPlugin, $xtLink, $db;

$products_id = (int)$products_id;

if ($products_id=='') return false;

/*added code*/

//$quer = "SELECT products_id, products_master_model FROM ".TABLE_PRODUCTS." WHERE products_master_model!=''";

//$resus = $db->CacheExecute($quer);

/*added end*/

$query = "SELECT bop.products_id FROM ".TABLE_ORDERS_PRODUCTS." aop, ".TABLE_ORDERS_PRODUCTS." bop WHERE aop.products_id='".$products_id."' and aop.products_id!=bop.products_id and aop.orders_id = bop.orders_id group by bop.products_id";

$rs = $db->CacheExecute($query);

if ($rs->RecordCount()==0) return false;

$products = array();

/*added code*/

$record = $db->Execute("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE products_master_model != ''");

$data=array();

if($record->RecordCount() > 0){

while(!$record->EOF){

$data[] = $record->fields['products_id'];

$record->MoveNext();

}

}

/*added end*/

while (!$rs->EOF) {

$products[] = $rs->fields['products_id'];

$rs->MoveNext();

}

/*added code*/

$out=array();

foreach($products as $v){

if(in_array($v, $data)){

$master=array();

$masterid=array();

$rec = $db->Execute("SELECT products_master_model FROM ".TABLE_PRODUCTS." WHERE products_id = '".$v."'");

if($rec->RecordCount() > 0){

//echo "ja";

while(!$rec->EOF){

$master[] = $rec->fields['products_master_model'];

$rec->MoveNext();

}

$rec = $db->Execute("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE products_model = '".$master[0]."'");

if($rec->RecordCount() > 0){

while(!$rec->EOF){

$masterid[] = $rec->fields['products_id'];

$rec->MoveNext();

}

if(!in_array($masterid[0], $out)) $out[] = $masterid[0];

}

}

}else $out[]=$v;

}

$products=$out;

/*added end*/

// shuffle if more than max

if (XT_ALSO_PURCHASED_MAX_DISPLAY<$rs->RecordCount()) {

shuffle($products);

$products = array_slice($products, 0,XT_AUTO_CROSS_SELL_MAX_DISPLAY);

}

$module_content = array();

$inmodcont=array();

$size = 'default';

foreach ($products as $key => $val) {

$product = & new product($val,$size);

if ($product->is_product){

$module_content[] = $product->data;

}

}

return $module_content;

}

/**

* auto cross selling for shopping cart display

*

*/

function getAutoCrossSellProductListingCart() {

global $xtPlugin, $xtLink, $db;

if (count($_SESSION['cart']->content)<1) return false;

$ids = array();

foreach ($_SESSION['cart']->content as $key => $val) {

$ids[]=$val['products_id'];

}

$query = "SELECT bop.products_id FROM ".TABLE_ORDERS_PRODUCTS." aop, ".TABLE_ORDERS_PRODUCTS." bop WHERE aop.products_id IN (".implode(',',$ids).") and aop.products_id!=bop.products_id and aop.orders_id = bop.orders_id group by bop.products_id";

$rs = $db->CacheExecute($query);

if ($rs->RecordCount()==0) return false;

$products = array();

/*added code*/

$record = $db->Execute("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE products_master_model != ''");

$data=array();

if($record->RecordCount() > 0){

while(!$record->EOF){

$data[] = $record->fields['products_id'];

$record->MoveNext();

}

}

/*added end*/

while (!$rs->EOF) {

if (!in_array($rs->fields['products_id'],$ids)) $products[] = $rs->fields['products_id'];

$rs->MoveNext();

}

/*added code*/

$out=array();

foreach($products as $v){

if(in_array($v, $data)){

$master=array();

$masterid=array();

$rec = $db->Execute("SELECT products_master_model FROM ".TABLE_PRODUCTS." WHERE products_id = '".$v."'");

if($rec->RecordCount() > 0){

//echo "ja";

while(!$rec->EOF){

$master[] = $rec->fields['products_master_model'];

$rec->MoveNext();

}

$rec = $db->Execute("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE products_model = '".$master[0]."'");

if($rec->RecordCount() > 0){

while(!$rec->EOF){

$masterid[] = $rec->fields['products_id'];

$rec->MoveNext();

}

if(!in_array($masterid[0], $out)) $out[] = $masterid[0];

}

}

}else $out[]=$v;

}

$products=$out;

/*added end*/

// shuffle if more than max

if (XT_ALSO_PURCHASED_MAX_DISPLAY<$rs->RecordCount()) {

shuffle($products);

$products = array_slice($products, 0,XT_AUTO_CROSS_SELL_MAX_DISPLAY);

}

$module_content = array();

foreach ($products as $key => $val) {

$size = 'default';

$product = & new product($val,$size);

if ($product->is_product)

$module_content[] = $product->data;

}

return $module_content;

}

Link to comment
Share on other sites

...und entsprechend in der class.cross_selling.php

function getCrossSellingProductListing($products_id) {

global $xtPlugin, $xtLink, $db;

$products_id = (int)$products_id;

if ($products_id=='') return false;

$this->sql_products->setPosition('cross_selling');

$this->sql_products->setSQL_TABLE("INNER JOIN " . TABLE_PRODUCTS_CROSS_SELL . " pc ON p.products_id = pc.products_id_cross_sell");

$this->sql_products->setSQL_WHERE("and pc.products_id ='".$products_id."'");

$this->sql_products->setSQL_WHERE("and pc.products_id_cross_sell=p.products_id");

$query = $this->sql_products->getSQL_query();

$rs = $db->CacheExecute($query);

if ($rs->RecordCount()==0) return false;

$cross_sell_products = array();

/*added code*/

$record = $db->Execute("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE products_master_model != ''");

$data=array();

if($record->RecordCount() > 0){

while(!$record->EOF){

$data[] = $record->fields['products_id'];

$record->MoveNext();

}

}

/*added end*/

while (!$rs->EOF) {

$cross_sell_products[] = $rs->fields['products_id'];

$rs->MoveNext();

}

/*added code*/

$out=array();

foreach($cross_sell_products as $v){

if(in_array($v, $data)){

$master=array();

$masterid=array();

$rec = $db->Execute("SELECT products_master_model FROM ".TABLE_PRODUCTS." WHERE products_id = '".$v."'");

if($rec->RecordCount() > 0){

//echo "ja";

while(!$rec->EOF){

$master[] = $rec->fields['products_master_model'];

$rec->MoveNext();

}

$rec = $db->Execute("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE products_model = '".$master[0]."'");

if($rec->RecordCount() > 0){

while(!$rec->EOF){

$masterid[] = $rec->fields['products_id'];

$rec->MoveNext();

}

if(!in_array($masterid[0], $out)) $out[] = $masterid[0];

}

}

}else $out[]=$v;

}

$products=$out;

/*added end*/

// shuffle if more than max

if (XT_CROSS_SELLING_MAX_DISPLAY<$rs->RecordCount()) {

shuffle($cross_sell_products);

$cross_sell_products = array_slice($cross_sell_products, 0,XT_CROSS_SELLING_MAX_DISPLAY);

}

$module_content = array();

foreach ($cross_sell_products as $key => $val) {

$size = 'default';

$product = & new product($val,$size);

$module_content[] = $product->data;

}

return $module_content;

}

...ich glaube, das ist gar nicht nötig, denn man kann ohnehin im cross-selling keine slaveartikel als ziel wählen.

Link to comment
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...