Zen Cart Logo
Forums / General Questions / Looking to migrate to ZenCart from OSC

Looking to migrate to ZenCart from OSC

Views: 13,055

Results 101 to 120 of 200
24 May 2014, 10:55 AM
#101
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Looking to migrate to ZenCart from OSC

Silly me!!!! I had another look at the code and realised that I was continually going through the function with the same master category ID!!!!

I'm nearly there now and will post the final code once it's completed

24 May 2014, 11:06 AM
#102
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

DigiBooks:

Silly me!!!! I had another look at the code and realised that I was continually going through the function with the same master category ID!!!!

I'm nearly there now and will post the final code once it's completed

OK it's all working now - the final code changes are this:

In includes/modules/new_products.php

AFTER: while (!$new_products->EOF) {

ADD:

// DB#2 BEGIN - read in author's name
$new_manufacturer = zen_get_products_manufacturers_name($new_products->fields['products_id']);
// END DB#2

// DB#3 BEGIN - read in the book's master category ID
$new_category_master_id = zen_get_products_category_id($new_products->fields['products_id']);
// and find the top-level genre
$new_toplevel_genre_id = zen_get_toplevel_category_id($new_category_master_id);
// now collect the genre's name
$new_genre_name = zen_get_categories_name($new_toplevel_genre_id);
// END DB#3

find the line that starts: 'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' .

and replace the whole of the code with:

'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . 
	
// DB#2 BEGIN - display author and remove pricing information
'</a><br />by<br />' . $new_manufacturer
// END DB#2

// DB#3 BEGIN - display the top-level genre
. '<br />(' . $new_genre_name . ')');
// END DB#3

In includes/functions/functions_lookup

ADD:

/* DB#1 BEGIN - extract the top-level genre

  • TABLES: categories
    */
    function zen_get_toplevel_category_id($this_category_id) {
    global $db;
    global $is_toplevel_category;
    global $this_parent_id;

    $is_toplevel_category = $this_category_id;
    $this_parent_id = 9;

    do {
    $the_toplevel_category_query = "select categories_id, parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . $is_toplevel_category . "'";
    $the_toplevel_category = $db->Execute($the_toplevel_category_query);

       $is_toplevel_category = $the_toplevel_category->fields['parent_id'];
       $this_parent_id = $the_toplevel_category->fields['parent_id'];
    

    } while ($this_parent_id >0);

       $is_toplevel_category = $the_toplevel_category->fields['categories_id'];
    

    return $is_toplevel_category;
    }

/* END DB#1 */

24 May 2014, 1:00 PM
#103
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Looking to migrate to ZenCart from OSC

To get a Top parent for a Product you could use:

$chk_parent_id = zen_get_product_path($product_id);

$chk_parent_id then has the full path to the Product, such as XXX_YYY_ZZZ

Then the (int)$chk_parent_id would be the parent XXX ...

24 May 2014, 1:04 PM
#104
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Ajeh:

To get a Top parent for a Product you could use:

$chk_parent_id = zen_get_product_path($product_id);

> 
> $chk_parent_id then has the full path to the Product, such as XXX_YYY_ZZZ
> 
> Then the (int)$chk_parent_id would be the parent XXX ...

Oh wow!!!!  I didn't know about this.  So are you saying that to obtain the top-level category name I would use:

$new_genre_name = zen_get_categories_name((int)$chk_parent_id);
??
24 May 2014, 1:25 PM
#105
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Looking to migrate to ZenCart from OSC

No ... I am saying to get a Product's top level caetgories_id you can use that ...

Then from that you could get the name with:

$chk_parent_name = zen_get_category_name((int)zen_get_product_path([B]$products_id[/B]), (int)$_SESSION['languages_id']);

You just need the products_id for that ...

NOTE: you have to supply the language_id via the:
(int)$_SESSION['languages_id']

for that function ...

24 May 2014, 1:32 PM
#106
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

DigiBooks:

Oh wow!!!! I didn't know about this. So are you saying that to obtain the top-level category name I would use:

$new_genre_name = zen_get_categories_name((int)$chk_parent_id);
??

I just tried the above and it works!!!! Thank you so much!!!!

The code I wrote was not wasted because it gave me a lot of insight into how the system works.

Again I can only thank everyone for all the assistance you have given me and again it proves that Zencart is far superior to OSC :)

(I have now amended the code!)

24 May 2014, 1:34 PM
#107
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

DigiBooks:

I just tried the above and it works!!!! Thank you so much!!!!

The code I wrote was not wasted because it gave me a lot of insight into how the system works.

Again I can only thank everyone for all the assistance you have given me and again it proves that Zencart is far superior to OSC :)

(I have now amended the code!)

Thanks Ajeh - was posting the same time as you LOL! I will amend as you suggest - and thank you :)

24 May 2014, 1:47 PM
#108
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Looking to migrate to ZenCart from OSC

You are most welcome ...

You should read through the functions in the /includes/functions directory ...

For example, another function zen_get_categories_name can get the name just from the category without the language_id being passed to it as it assumes the current language ...

24 May 2014, 2:00 PM
#109
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Ajeh:

You are most welcome ...

You should read through the functions in the /includes/functions directory ...

For example, another function zen_get_categories_name can get the name just from the category without the language_id being passed to it as it assumes the current language ...

I was looking through the functions directory but I missed this one! As you will see from the rest of the thread I am still very green on PHP but learning fast with all your help. :)

Your solution has taken all my additional code and turned it into one line of code - WOW!!!!

I did add additional code for another section and will change that also and post all the results here - thanks

24 May 2014, 2:10 PM
#110
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Looking to migrate to ZenCart from OSC

Give yourself time ... there are a lot of things about Zen Cart to learn but there are also a lot of things about Zen Cart to help make your life easier ...

You are zipping along well and the folks here are a friendly bunch to help you when you get stuck ... :cool:

24 May 2014, 2:37 PM
#111
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Ajeh:

Give yourself time ... there are a lot of things about Zen Cart to learn but there are also a lot of things about Zen Cart to help make your life easier ...

You are zipping along well and the folks here are a friendly bunch to help you when you get stuck ... :cool:

I know I'm trying to sort of 'rush' through it .... just fed up of the OSC site and want to get to a basic ZC site with fully working downloads then I can slow down and sort the niceties :)

24 May 2014, 3:32 PM
#112
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Ajeh:

No ... I am saying to get a Product's top level caetgories_id you can use that ...

Then from that you could get the name with:

$chk_parent_name = zen_get_category_name((int)zen_get_product_path([B]$products_id[/B]), (int)$_SESSION['languages_id']);

> 
> You just need the products_id for that ...
> 
> NOTE: you have to supply the language_id via the:
> (int)$_SESSION['languages_id']
> 
> for that function ...

With Ajeh's assistance the final New Products output with Book Title, Author and top-level Genre has been reduced to this:

In catalog/includes/modules/new_products.php:

AFTER:

  while (!$new_products->EOF) {


ADD:

// DB#2 BEGIN - read in author's name
			$new_manufacturer = zen_get_products_manufacturers_name($new_products->fields['products_id']);
// END DB#2

// DB#3 BEGIN - read in the top-level category name
	$chk_parent_name = zen_get_category_name((int)zen_get_product_path($new_products->fields['products_id']), (int)$_SESSION['languages_id']);
// END DB#3


find the line starting:    'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . 

and replace the whole code with:

    'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . 
		
	// DB#2 BEGIN - display author and remove pricing information
	'</a><br />by<br />' . $new_manufacturer
	// END DB#2

	// DB#3 BEGIN - display the top-level genre
	. '<br />(' . $chk_parent_name . ') <br />');
	// END DB#3


RESULT:

Attachment 14104
24 May 2014, 3:37 PM
#113
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Looking to migrate to ZenCart from OSC

That looks pretty snazzy ... :smile:

24 May 2014, 4:00 PM
#114
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Ajeh:

That looks pretty snazzy ... :smile:

Having taken Ajeh's fix one step further I have achieved this:

In catalog/includes/modules/pages/product_info/main_template_vars.php

AFTER:

$manufacturers_name= zen_get_products_manufacturers_name((int)$_GET['products_id']);

ADD:

// DB#1 BEGIN - read in the top-level category name
$chk_parent_name = zen_get_category_name((int)zen_get_product_path($product_info->fields['products_id']), (int)$_SESSION['languages_id']);
// END DB#1

In catalog/includes/templates/template_default/templates/tpl_product_info_display.php

find: <!--bof Product Name-->

and replace down to <!--eof Product Name-->

with:

<!--bof Product Name--> <h1 id="productName" class="productGeneral"> <?php echo $products_name // DB#1 BEGIN - move author's name to below the book title . '<br /><h3>by ' . $manufacturers_name . '</h3>' . '<br /><strong>(Genre: ' . $chk_parent_name . ')</strong>'; // END DB#1 ?> </h1> <!--eof Product Name-->

RESULT:

Attachment 14105

10 Jun 2014, 5:57 PM
#115
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

OK guys ... I have been working away in the background and making the changes I need (using the Developer's Tool Kit to find where I should be) but I have hit a little snag!

I have been playing around with the layouts in includes/modules/product_listing.php quite successfully until I get to the bit where I don't want to show the first 150 characters of a book description ... I want to show 300.

So I have tracked down the function: zen_trunc_string (the full line in the above is: zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) ) and found:

function zen_trunc_string($str = "", $len = 150, $more = 'true') {

I changed the 150 to 300 ... but it still truncates at 150 characters............

Any ideas please?

Thanks

10 Jun 2014, 6:09 PM
#116
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Looking to migrate to ZenCart from OSC

Did you change the setting in the Configuration ... Product Listing ...

Display Product Description
Do you want to display the Product Description?

0= OFF
150= Suggested Length, or enter the maximum number of characters to display

10 Jun 2014, 6:17 PM
#117
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Ajeh:

Did you change the setting in the Configuration ... Product Listing ...

That'll do it Ajeh LOL!

That's why OSCommerce is **** and Zencart has it's act together!

Thank you

10 Jun 2014, 6:22 PM
#118
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Looking to migrate to ZenCart from OSC

Thanks for the update that this is working for you and was simply a flip of a switch ... :smile:

10 Jun 2014, 6:23 PM
#119
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Ajeh:

Thanks for the update that this is working for you and was simply a flip of a switch ... :smile:

You're welcome and thanks again.

I'll get to the complicated stuff once I manage to transfer over 6,000 books across from OSC :)

10 Jun 2014, 10:26 PM
#120
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Looking to migrate to ZenCart from OSC

DigiBooks:

You're welcome and thanks again.

I'll get to the complicated stuff once I manage to transfer over 6,000 books across from OSC :)

You could use Easy Populate to import the books into ZC. Take a sneak view into the Plugins section (link on top of this page).

You would need to export your books from OSC using something similar to EP, export in csv format then tweak the headings etc to match the requirement of EP before importing.

Backup everything before attempting this.