Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Divide aplication_top.php


bhbilbao

Recommended Posts

Hi Folks!

 

for one of my projects with OSCOMMERCE 2.2RC2A, I need to create a lightweight version of application_top.php only with the code to get the $category_depth and $current_category_id.

 

I created I new file named application_top_path.php, but i Think I need other code inside it.

 

Need suggestion of the experts. This is important.

 

The modified index.php

<?php
/*
$Id: index.php 1739 2007-12-20 00:52:16Z hpdl $
version OSCOMMERCE 2.2RC2A
*/
require('includes/application_top_path.php');

// the following cPath references come from application_top_path.php
$category_depth = 'top';
if (isset($cPath) && tep_not_null($cPath)) {
$categories_products_query = tep_db_query("select count(*) as total from products_to_categories where categories_id = '" . (int)$current_category_id . "'");
$cateqories_products = tep_db_fetch_array($categories_products_query);
if ($cateqories_products['total'] > 0) {
 $category_depth = 'products'; // display products
} else {
 $category_parent_query = tep_db_query("select count(*) as total from categories where parent_id = '" . (int)$current_category_id . "'");
 $category_parent = tep_db_fetch_array($category_parent_query);
 if ($category_parent['total'] > 0) {
 $category_depth = 'nested'; // navigate through the categories
 } else {
 $category_depth = 'products'; // category has no products, but display the 'no products' message
 }
}
}

<?php
if (isset($cPath) && strpos('_', $cPath)) {
require('includes/application_top.php'); //original
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);
....

 

 

application_top_path.php

<?php
/*
$Id: application_top_path.php 1833 2013-01-30 22:03:30Z hpdl $
$Loc: /catalog/includes/ $
adapted for NewProject
*/
// Generate a path to categories
function tep_get_path($current_category_id = '') {
// BOF optimize categories box
global $cPath_array, $countproducts;

if (tep_not_null($current_category_id)) {
 $cp_size = sizeof($cPath_array);
 if ($cp_size == 0) {
 $cPath_new = $current_category_id;
 } else {
 $cPath_new = '';
 if (is_object($countproducts)) {
	 $last_category['parent_id'] = $countproducts->getParentCategory((int)$cPath_array[($cp_size-1)]);
 } else {
 $last_category_query = tep_db_query("select parent_id from categories where categories_id = '" . (int)$cPath_array[($cp_size-1)] . "'");
 $last_category = tep_db_fetch_array($last_category_query);
 }

 if (is_object($countproducts)) {
	 $current_category['parent_id'] = $countproducts->getParentCategory((int)$current_category_id);
 } else {
 $current_category_query = tep_db_query("select parent_id from categories where categories_id = '" . (int)$current_category_id . "'");
 $current_category = tep_db_fetch_array($current_category_query);
 }
// EOF optimize categories box
 if ($last_category['parent_id'] == $current_category['parent_id']) {
	 for ($i=0; $i<($cp_size-1); $i++) {
	 $cPath_new .= '_' . $cPath_array[$i];
	 }
 } else {
	 for ($i=0; $i<$cp_size; $i++) {
	 $cPath_new .= '_' . $cPath_array[$i];
	 }
 }
 $cPath_new .= '_' . $current_category_id;

 if (substr($cPath_new, 0, 1) == '_') {
	 $cPath_new = substr($cPath_new, 1);
 }
 }
} else {
 $cPath_new = implode('_', $cPath_array);
}

return 'cPath=' . $cPath_new;

} # end of function Generate a path to categories
?>

 

Thanks in advance.

Link to comment
Share on other sites

What exactly is your goal?

 

The application_top controls everything, from the URL structer to sessions to loading classes and functions. It can be slimmed down some, but not to aweful much.

Follow the community build:

BS3 to osCommerce Responsive from the Get Go!

Check out the new construction:

Admin Gone to Total BS!

Link to comment
Share on other sites

Unless application_top.php is doing something that you don't want it to do (necessitating your making a stripped-down version), you have to ask yourself whether it's worth the effort. Besides the development time, you'll have to maintain it in parallel with the "official" version, and be responsible for any problems it causes by omitting parts of the official code. Maybe you'll save a little execution time, but is it worth the effort? What is your goal? If you're using application_top.php in some new file, it can be argued that simply plugging in the standard version is worth the reduced development time, even though run time would be somewhat reduced with a stripped version.

Link to comment
Share on other sites

Thanks Websorce5 and Mr.Phil for your responses,

the goal is to load another software at the end of index.php without all the code of aplication_top.php. In this way, this software would loads pages about 10 second faster, because there is no osc code.

 

 

End of index.php about line 290:

<?php
} else { // default page (we load another default page without aplication_top.php code.... only loads the get $path before
?>

Link to comment
Share on other sites

10 seconds??? You have a very poorly performing server if application_top.php takes that long to run!

Yeah, the problem is that my OSC2.2 has about 300 addons instaled and the new CRM software has 70 plugins. For the moment they work fine together with some <head> </head> modifications ("headers already sent" problem solved).

I only want the CRM to load with only the $cpath code in index.php(default part).

 

Do you understand me??

What portions of code to add the application_top_path.php file only for make work the $cpath conditional??

 

I will continue myself looking general.php configure.php etc.. I think It could't be difficult but is extrange that nobody made it before. All examples I saw during last years are about installing OSC in diferent server folder, but my software needs OSC to be in the same root and then share some archives OSC<>CRM.

Link to comment
Share on other sites

  • 3 weeks later...

Why don't you comment out sections in application_top, figuring out what is needed for cPath to work is not rocket science.

If you only need cPath, and not your 300 addon additions, why don't you load up the vanilla application_top ?

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

  • 4 weeks later...

I made that. Loaded vanilla aplication_top.php

 

But same problem, to work needs configure.php, database_tables.php, usu5 code, general.php, functions.php, sessions.php, languages.php, database.php, and other classes line shooping_cart.

 

Practically I removed the addons code for another file and is working but only saves 2-4 seconds.(OSC practically needs all vanilla code to work)

 

In other way, I started a new project and also working with OSCOMMERCE 2.2RC2 + WORDPRESS 3.5.2 + BOOTSTRAP3 installed in root with same database and working! but same problems.. bad loading results from 5-15 seconds depending page.

 

Thanks for all bruyndoncx.

Link to comment
Share on other sites

there are different ways to improve oscommerce speed

if you have apc cache in your hosting environment, turn it on

set category counts off

add some indexes,

there is a contribution that can help in finding the performance bottle neck by FWR media if I remember well

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...