Jump to content

Show Inactive Product Page - when visited directly


disco_ii_disco

Recommended Posts

Hi all,

I like to still provide access to inactive products visible, when visited directly - rather than displaying a 404 page.

(Some of these products get plenty of visitors from Google as no one else lists them anymore.)

Whilst the product is no longer available to buy, we do have alternative products listed on the page - and it might just be that the product has been superceeded.

I don't want the inactive products to appear in category pages.

The only way I can see to do this is by overwriting line 1037 in the catalogue.class (inside the getProductData function) to: 

$where = $this->outOfStockWhere(array('product_id' => $product_id));

Am I missing anyway of doing this without hacking the code?

Regards,

Chris

 

 

Link to comment
Share on other sites

  • 2 weeks later...

That is one of the edits I did. Others are needed. The end result is to ignore a product's status only when calling a certain function from certain, key locations that requests a product's details.

Unfortunately, CubeCart uses this function in a frivolous manner from one location, so it needs to be dealt with as well.

Please try these edits:

In /classes/catalogue.class.php, find the public function getProductData.

From:

public function getProductData($product_id, $quantity = 1, $order = false, $per_page = 10, $page = 1, $category = false, $options_identifier = null)

To:

public function getProductData($product_id, $quantity = 1, $order = false, $per_page = 10, $page = 1, $category = false, $options_identifier = null, $_status = true)

Then, about sixteen lines later:

From:

$where = $this->outOfStockWhere(array('product_id' => $product_id, 'status' => 1));

To:

$arrIPS['product_id'] = $product_id; if ($_status) $arrIPS['status'] = 1;
$where = $this->outOfStockWhere($arrIPS);
In /classes/catalogue.class.php, find the public function displayProduct. Three lines into the function:

From:

if (($product = $this->getProductData($product)) !== false) {

To:

if (($product = $this->getProductData($product,1,false,10,1,false,null,false)) !== false) {
In /classes/cubecart.class.php, find the public function _product. Two lines into the function:

From:

if (($product = $GLOBALS['catalogue']->getProductData($_GET['product_id'])) === false) {

To:

if (($product = $GLOBALS['catalogue']->getProductData($_GET['product_id'],1,false,10,1,false,null,false)) === false) {

These changes will collect the product's data irrespective of it's status, and thus display the page normally. That means, it should have a stock level greater than zero, or have store set to show out-of-stock items.

Save these instructions as an upgrade will overwrite these changes.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...