Jump to content

List ALL products link - is this possible?


vidmarc

Recommended Posts

Initially, we are at /classes/cubecart.class.php, in the private function _category() where the call to search the catalogue is made. This statement:

$GLOBALS['catalogue']->setCategory('cat_name', sprintf($GLOBALS['language']->catalogue['notify_product_search'], $_REQUEST['search']['keywords']));

gives us the Products found matching 'words' phrase.

We can execute a similar statement immediately after the above with what we want to display.

Immediately after that statement, add:

$GLOBALS['catalogue']->setCategory('cat_name', "Your Search Returned ".$Catalogue->_category_count." Products.");

But here is another problem-- this '_category_count' property of Catalogue is private. Catalogue includes this value as a parameter when making calls to other places, but other places cannot ask Catalogue for this value. Not without a specific function of Catalogue to answer such requests. (Note: there is the Category public function getCategoryData(), but this function first loads '_category_data' with fresh data from the database category table. This is not what we want. This function should maybe actually be called loadCategoryData().)

We will need to use a function of Catalogue, while we are in Catalogue, to incorporate the '_category_count' into a variable that we can later ask for outside Catalogue.

In the Catalogue class file, public function searchCatalogue(), starting at the bottom of the function, look for:

$this->_category_count  = (int)count($count);

There will be three instances of this statement. On a new blank line after each occurance, add:

$this->setCategory('category_count', $this->_category_count);

Next, we now need the function to allow an outside place to ask for this value.

In the Catalogue class file:

Find:

//=====[ Private ]=======================================

On a new blank line just ABOVE it, add:

	/**
	 * Get category property
	 *
	 * @param string $id
	 * @return mixed
	 */
	public function getCategory($id) {
		return $this->_categoryData[$id];
	}

Finally, we now have a good statement to add in the CubeCart class file -- the first edit made:

$GLOBALS['catalogue']->setCategory('cat_name', "Your Search Returned ".$GLOBALS['catalogue']->getCategory('category_count')." Products.");

 

Link to comment
Share on other sites

  • 7 months later...

The only way I can get this to work (simply) is to add a new top category called "Store", and then add each product menu item as a sub-category of "Store". Unless there's any other way of doing this since I was last here?

Here are the menu items/categories I have so far. https://www.mondo-macabro.com/

 

Link to comment
Share on other sites

On 8/14/2018 at 2:40 PM, bsmither said:

Try:
/search.html?search[keywords]=*&_a=category 

This seems like a good option - but can I modify the link to list only in-stock items from all categories?

Link to comment
Share on other sites

By asking this question, we can assume you choose to show out-of-stock items everywhere else? Otherwise, in admin, Store Settings, Stock tab, set the "Hide out-of-stock product" setting to checked. (To verify its operation, log out of admin, or use a different browser.)

Link to comment
Share on other sites

There is a bug in CC624 that is thwarting my attempts to create a URL that will show only in-stock items.

/search.html?search[keywords]=*&_a=category&search[inStock]=1

The above is the URL I am working with.

Link to comment
Share on other sites

Thanks for your help with this - I'm sure it is possible, somehow...

It must be possible to generate a valid search query via the advanced search form:

/search.html

It has an "in stock" option. But I can't find the best way to list all items. The asterisk doesn't work.

Perhaps the advanced search form needs expanding to allow more search terms, for example a wild card and "category".

Link to comment
Share on other sites

Depending on your skin, there may be a All link at the end of pagination.

The URL we are experimenting with, where one can place this link on any other site or any other location in your store, would be:

search.html?search[keywords]=*&_a=category&page=all

Hopefully, you have a sane amount of products to be showing all of them at one time. (I think there may be a limit in the code for 100 items.) Or your hosting site has given you a dedicated server and database.

Link to comment
Share on other sites

Try this:

In the template content.category.php, find:

<h2>{$category.cat_name}</h2>

Change to:

{if $VAL_SELF|strpos:'search.html'}<h2>Your search produced {$TOTAL_RESULTS} results...</h2>{/if}
<h2>{$category.cat_name}</h2>
Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

Archived

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

×
×
  • Create New...