Skip to content

Commit

Permalink
fix product search spidering and view links
Browse files Browse the repository at this point in the history
  • Loading branch information
illiphilli committed Jul 22, 2011
1 parent 8832af8 commit d3f526c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 51 deletions.
7 changes: 4 additions & 3 deletions framework/core/subsystems/expPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ public function __construct($params=array()) {
}
}

$this->runCallback();
if (!isset($params['records'])) $this->runCallback(); // isset($params['records']) added to correct search for products.
//$this->runCallback();

//eDebug($this->records);
// get the number of the last record we are showing...this is used in the page links.
// i.e. "showing 10-19 of 57"...$this->last would be the 19 in that string
Expand Down Expand Up @@ -309,8 +311,7 @@ public function __construct($params=array()) {
$table_template = get_common_template('pagination_table', null, 'common');
$table_template->assign('page', $this);
$this->table = $table_template->render();
// eDebug($this);
//eDebug($this);


}

Expand Down
63 changes: 24 additions & 39 deletions framework/modules/ecommerce/products/datatypes/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class product extends expRecord {

protected $attachable_item_types = array(
'content_expFiles'=>'expFile',
'content_expRatings'=>'expRating',
'content_expComments'=>'expComment',
//'content_expTags'=>'expTag',
//'content_expComments'=>'expComment',
'content_expSimpleNote'=>'expSimpleNote',
);

Expand Down Expand Up @@ -90,14 +90,7 @@ function incrementQuantity($oldval) {
}

function updateQuantity($newval) {
if($this->allow_partial)
{
return floatval($newval);
}
else
{
return intval($newval);
}
return $newval;
}

function getBasePrice($orderitem=null) {
Expand Down Expand Up @@ -157,7 +150,8 @@ function addToCart($params, $orderid = null) {
if ($orderid == null) global $order;
else $order = new order($orderid);
//eDebug($this);
$params['quantity'] = isset($params['quantity']) ? $params['quantity'] : 1;
//eDebug($params,true);
$params['qty'] = isset($params['qty']) ? $params['qty'] : 1;
if (!isset($params['product_type'])) $params['product_type'] = 'product';

$params['error'] = '';
Expand All @@ -175,7 +169,7 @@ function addToCart($params, $orderid = null) {
if($orderItem->product_id == $this->id) $qCheck += $orderItem->quantity;
}
//}
$qty = $params['quantity'];
$qty = $params['qty'];
if (($this->quantity - $qCheck) < $qty) {
if ($this->availability_type == 2) {
flash('error', $this->title.' only has '.$this->quantity.' on hand. You can not add more than that to your cart.');
Expand All @@ -187,12 +181,11 @@ function addToCart($params, $orderid = null) {
if (($qty + $qCheck) < $this->minimum_order_quantity)
{
flash('message', $this->title.' has a minimum order quantity of '.$this->minimum_order_quantity.'. The quantity has been adjusted accordingly.');
$params['quantity'] += $this->minimum_order_quantity - ($qty + $qCheck);
$qty = $params['quantity'];
$params['qty'] += $this->minimum_order_quantity - ($qty + $qCheck);
$qty = $params['qty'];
}
}else
{
eDebug($params);
foreach ($params['children'] as $idKey=>$childQty)
{
$cprod = new childProduct($idKey);
Expand All @@ -207,19 +200,16 @@ function addToCart($params, $orderid = null) {
if($orderItem->product_id == $idKey) $qCheck += $orderItem->quantity;
}
//}

/*eDebug("Qty:".$childQty);
eDebug("Product Quantity:".$cprod->quantity);
eDebug("Qcheck:".$qCheck,true);*/
if (($cprod->quantity - $qCheck) < $childQty) {
if ($cprod->availability_type == 2) {
flash('error', $this->title. ' - ' .$cprod->model. ' only has '.$cprod->quantity.' on hand. You can not add more than that to your cart.');
//return false;
expHistory::back();
}
}
/*eDebug("Current Qty Adding:".$childQty);
eDebug("Product Quantity On Hand:".$cprod->quantity);
eDebug("Prod min order qty:" . $cprod->minimum_order_quantity);
eDebug("Current Qty In Cart:".$qCheck); */

//check minimum quantity
if (($childQty + $qCheck) < $cprod->minimum_order_quantity)
{
Expand Down Expand Up @@ -291,10 +281,9 @@ function addToCart($params, $orderid = null) {
}else{
foreach ($params['children'] as $ckey=>$cqty)
{
//$params['qty'] = 1;
$params['quantity'] = $cqty;
//for ($qty=1; $qty<=$cqty; $qty++)
// {
$params['qty'] = 1;
for ($qty=1; $qty<=$cqty; $qty++)
{
$child = new $params['product_type']($ckey); //$params['prod-quantity'][$ckey];
$this->createOrderItem($child, $params, $user_input_info, $orderid);

Expand All @@ -303,7 +292,7 @@ function addToCart($params, $orderid = null) {
if ($child->id == $ckey) $this->createOrderItem($child, $params, $user_input_info);
break;
}*/
//}
}

}
//die();
Expand Down Expand Up @@ -389,7 +378,7 @@ private function createOrderItem($product, $params, $user_input_info, $orderid)
eDebug($params);
eDebug($product->minimum_order_quantity);*/

$item->quantity += is_numeric($params['quantity']) && $params['quantity'] >= $product->minimum_order_quantity ? $params['quantity'] : $product->minimum_order_quantity;
$item->quantity += is_numeric($params['qty']) && $params['qty'] >= $product->minimum_order_quantity ? $params['qty'] : $product->minimum_order_quantity;
if ($item->quantity < 1 ) $item->quantity = 1;
// eDebug($item->quantity,true);
//eDebug($params);
Expand Down Expand Up @@ -421,19 +410,15 @@ public function removeItem($item) {
return true;
}


public function process($item, $affects_inventory) {


public function process($item) {
global $db;
//only adjust inventory if the order type says it should, or we otherwise tell it to
if($affects_inventory)
{
$this->quantity = $this->quantity - $item->quantity;
//$this->save();
$pobj->id = $this->id;
$pobj->quantity = $this->quantity;
$db->updateObject($pobj, 'product', 'id='.$this->id);
}
return;
$this->quantity = $this->quantity - $item->quantity;
//$this->save();
$pobj->id = $this->id;
$pobj->quantity = $this->quantity;
$db->updateObject($pobj, 'product', 'id='.$this->id);
}

public function optionDropdown($key, $display_price_as) {
Expand Down
15 changes: 8 additions & 7 deletions framework/modules/search/controllers/searchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ public function search() {
$terms = stripslashes($terms);
}


$search = new search();
$page = new expPaginator(array(
'model'=>'search',
'controller'=>$this->params['controller'],
'action'=>$this->params['action'],
'records'=>$search->getSearchResults($terms),
//'sql'=>$sql,
'order'=>'score',
'dir'=>'DESC',
//'model'=>'search',
'controller'=>$this->params['controller'],
'action'=>$this->params['action'],
'records'=>$search->getSearchResults($terms),
//'sql'=>$sql,
'order'=>'score',
'dir'=>'DESC',
));

assign_to_template(array('page'=>$page, 'terms'=>$terms));
Expand Down
4 changes: 2 additions & 2 deletions framework/modules/search/views/search/search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{foreach from=$page->records item=result}
{*if $result->canview == 1*}
<div class="item {cycle values="odd,even"}">
<a href="{$smarty.const.URL_FULL}{$result->view_link}">{$result->title}</a>
<a href="{$result->view_link}">{$result->title}</a>
{if $result->body != ""}<br /><span class="summary">{$result->body|strip_tags|truncate:240}</span>{/if}
{clear}
</div>
Expand All @@ -36,7 +36,7 @@
<h2><a name="#{$category}">{$category} matching "{$query}":</a></h2>
{foreach from=$subresults item=result}
<div class="item {cycle values="odd,even"}">
<a href="{$smarty.const.URL_FULL}{$result->view_link}">{$result->title}</a>
<a href="{$result->view_link}">{$result->title}</a>
{if $result->sum != ""}<br /><span class="summary">{$result->sum}</span>{/if}
{*<br /><span class="search_result_item_link">{$result->view_link}</span>*}
</div>
Expand Down

0 comments on commit d3f526c

Please sign in to comment.