Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Heads Up: Crex Oscommerce Xml


Guest

Recommended Posts

Hi everyone!

 

I have added a contribution that I hope will allow for more "modularity" by separating data from presentation.

 

Usually, osCommerce has a bunch of its logic intertwined with embedded html. This requires PHP scripts and what not just to modify/interact with osCommerce.

 

But!

 

I made CREX osCommeRcE XML to allow developers to interact with osCommerce as a back-end, while allowing the developer to use a front-end of their liking (flash, ajax, GWT, etc...)

 

So, my question to you is... how can this contribution be used to help you? what other features would you like added?

 

(BTW, the official "sourceforge.net" page is http://crex.sourceforge.net/

 

Thanks!

Link to comment
Share on other sites

... Just another heads up ....

 

The "documentation" for it is at: http://crex.sourceforge.net/

 

 

As far as *what* CREX is... its "osCommeRcE XML"... and its aim is to provide a data layer completely separated from presentation via XML. In this way, a developer can make any kind of front end for any type of platform, be it a web browser on a mobile pc, an Adobe Flash eCommerce site, or even an AJAX web site (possibly using the Google Web Toolkit or what not).

 

Because CREX enables a means to interact with the osCommerce core with any XML enabled front end.... a designer is free to worry about designing only, while a developer is free to manipulate the XML data in any way he/she chooses.

 

I hope I explained it clearly... biggrin.gif

 

Post here if you have a question. I'll be more than happy to try and answere it!

Link to comment
Share on other sites

  • 1 month later...

******** UPDATE JULY 17 2007 ***********

 

Hi all! I have recently been working on CREX - osCommeRcE Xml... and have added some more commands!

 

The following is now part of the library:

 

-ability to retrieve product attributes

-get product reviews

-a function called "crex_create_option_list_xml()" that will create an series of xml nodes, instead of spitting out <ol> tags with values in them.

-THE ABILITY TO CHECK OUT.

 

I will be uploading some time friday night! The documentation is slow going, as I am bogged with work (to pay rent, eat, pay the greedy Cable Mongers, etc...) :D

 

As usually, constructive comments, questions... are always welcome!

Link to comment
Share on other sites

  • 4 weeks later...

hey i installed crex. i am using ms1 because of japanese language support. anyways, i do a get categories query and it returns

 

 

<root>

<data seo="SEO_ENABLED" cpath="" seo_link="http://{my web address}/default.php?cPath=" parent="" has_subcategories="true" product_count="917"></data>

</root>

 

is this the correct output, or should it give me all the categories?

any ideas?

giannimoto

Link to comment
Share on other sites

Would this allow me to import a stock quantity and price for various products from a supplier?

The format they send out in is

<RealData>
<MSG ID="10">Servlet down</MSG>
−
<ITEM>
<ID>343344</ID>
−
<DESC>
HP Ink Cartridge Black 830 sheet for DeskJet 7xx 8xx 970
</DESC>
<PRICE CURRENCY="GBP">12.96</PRICE>
<QTY>2619</QTY>
<DELDATE>2007-08-15</DELDATE>
</ITEM>
</RealData>

 

Regards

Shaun

Link to comment
Share on other sites

I was going to ask a similar question - How does this interact with a supplier like Techdata who provides an xml library to list products and interact with their server? Would I still need an additional front-end?

Link to comment
Share on other sites

hey i installed crex. i am using ms1 because of japanese language support. anyways, i do a get categories query and it returns

<root>

<data seo="SEO_ENABLED" cpath="" seo_link="http://{my web address}/default.php?cPath=" parent="" has_subcategories="true" product_count="917"></data>

</root>

 

is this the correct output, or should it give me all the categories?

any ideas?

giannimoto

 

Hi giannimoto,

 

I think something is wrong. The xml isnt showing any "cpath" info, perhaps the output should look more like this:

 

http://www.websitedesign1000.info/crex_rea...=get_categories

 

If you can get me a link to download the osCommerce version you have I will download it and try to figure it out

 

 

Glad to help,

-redpiersystems

Link to comment
Share on other sites

Would this allow me to import a stock quantity and price for various products from a supplier?

The format they send out in is

<RealData>
<MSG ID="10">Servlet down</MSG>
−
<ITEM>
<ID>343344</ID>
−
<DESC>
HP Ink Cartridge Black 830 sheet for DeskJet 7xx 8xx 970
</DESC>
<PRICE CURRENCY="GBP">12.96</PRICE>
<QTY>2619</QTY>
<DELDATE>2007-08-15</DELDATE>
</ITEM>
</RealData>

 

Regards

Shaun

 

Hi Shaun,

 

At the moment, crex doesnt have any mods to import stuff....yet. crex basically reads/writes to and from category/product info in the osCommerce database tables.

 

If there isn't a mod to import that data yet, lemme know... I'll see if i can whip something up for ya.

 

Hope I can help,

-redpiersystems

Link to comment
Share on other sites

Hi Shaun,

 

At the moment, crex doesnt have any mods to import stuff....yet. crex basically reads/writes to and from category/product info in the osCommerce database tables.

 

If there isn't a mod to import that data yet, lemme know... I'll see if i can whip something up for ya.

 

Hope I can help,

-redpiersystems

That would actually help me as well. The format Shaun is describing is one many of us may either use or would like to use, because that's the xml feed from a larger distributor.

 

EDIT: There IS an importer, I think. I've seen threads about it in several tech-related German websites, but I can't find the name or a link to the plugin itself in either English or German.

Edited by MattGSX
Link to comment
Share on other sites

hey i installed crex. i am using ms1 because of japanese language support. anyways, i do a get categories query and it returns

<root>

<data seo="SEO_ENABLED" cpath="" seo_link="http://{my web address}/default.php?cPath=" parent="" has_subcategories="true" product_count="917"></data>

</root>

 

is this the correct output, or should it give me all the categories?

any ideas?

giannimoto

 

There is a bug somewhere in the function that determines the language. This prevents the commands from returning just about anything. I have not tracked down the bug, but simply overridden the default value to be my own language. I suspect that is your problem too, as you say are japanese.

 

Around line 33 the crex_read.php change:

 

if (!$languages_id) $languages_id = '1';

 

to:

 

if (!$languages_id) $languages_id = 'your_language_code';

 

I hope this helps.

 

Cheers,

 

Andreas

Link to comment
Share on other sites

I found a bug that prevents output from being generated when you have products with status=0.

The crex_get_category_products_xml function does limit the query to only active products, but the function fails to check for returned data before proceeding to the XML functions, thereby generating an error when the array is empty.

 

To fix it, change the following code around line 296 in crex.php:

 

            $product_info = tep_db_fetch_array($product_info_query);
           //add the product as xml to our return value...
           $return_value .= crex_xml_data_node(crex_xml_from_array($product_info));
           $counter ++;
         }

 

to:

 

            $product_info = tep_db_fetch_array($product_info_query);
           //add the product as xml to our return value...
           if (!empty($product_info)){
           $return_value .= crex_xml_data_node(crex_xml_from_array($product_info));
           }
           $counter ++;
         }

 

Cheers,

 

Andreas

Link to comment
Share on other sites

There is a bug somewhere in the function that determines the language. This prevents the commands from returning just about anything. I have not tracked down the bug, but simply overridden the default value to be my own language. I suspect that is your problem too, as you say are japanese.

 

Around line 33 the crex_read.php change:

 

if (!$languages_id) $languages_id = '1';

 

to:

 

if (!$languages_id) $languages_id = 'your_language_code';

 

I hope this helps.

 

Cheers,

 

Andreas

 

Andreas,

 

Thanks for pointing that out! Sorry about that...ill make sure to fix that by the next file release (im short on time, im sorry )

 

There is a built in method for dealing with this (although, im guessing the language id for your particular language may have to be known beforehand for now):

 

try this:

Product XML (English, default)

 

..then, check out what happens when the language_id is added to that URL:

 

http://www.websitedesign1000.info/crex_rea...p;language_id=3

 

...for now, its a manual configuration...i'll be sure to fix that in the next release.

Link to comment
Share on other sites

try this:

Product XML (English, default)

 

..then, check out what happens when the language_id is added to that URL:

 

http://www.websitedesign1000.info/crex_rea...p;language_id=3

 

I understand.

 

First I would like to say that this contrib is excellent, it will solve my need to have my products displayed in a MODx frontend. Thank you for the work you put into this.

 

In my case, I don't use language ID 1, so there was no result returned. I didn't try using the language id in the URL as it was not in any of the examples or in the docs. Always pressed for time, this feature escaped me ;)

 

I didn't look into how this function worked, but I assumed you pulled the default language from the database somewhere and that there was a bug somewhere in that code. As I look closer now, it seems you rely on the URL to provide the language, and then fall back to a preset default if no language is specified in the URL.

It's ok too, but it was hard to guess upon first install and would surely trip up many international users ;) Changing this default value works well for me, and a note about setting this default value in the docs is all that is needed, imo.

 

In my case I also had some minor issues with character encoding as the OsC database uses ISO-8859-1 and my CMS uses UTF-8. I had to convert the returned data to UTF-8 and change the charset as well as including the encoding tag in the doctype.

 

Btw, is there a particular need for the ![CDATA[] tag of the data?

 

Cheers,

 

Andreas

Link to comment
Share on other sites

I understand.

 

First I would like to say that this contrib is excellent, it will solve my need to have my products displayed in a MODx frontend. Thank you for the work you put into this.

 

In my case, I don't use language ID 1, so there was no result returned. I didn't try using the language id in the URL as it was not in any of the examples or in the docs. Always pressed for time, this feature escaped me ;)

 

I didn't look into how this function worked, but I assumed you pulled the default language from the database somewhere and that there was a bug somewhere in that code. As I look closer now, it seems you rely on the URL to provide the language, and then fall back to a preset default if no language is specified in the URL.

It's ok too, but it was hard to guess upon first install and would surely trip up many international users ;) Changing this default value works well for me, and a note about setting this default value in the docs is all that is needed, imo.

 

In my case I also had some minor issues with character encoding as the OsC database uses ISO-8859-1 and my CMS uses UTF-8. I had to convert the returned data to UTF-8 and change the charset as well as including the encoding tag in the doctype.

 

Btw, is there a particular need for the ![CDATA[] tag of the data?

 

Cheers,

 

Andreas

 

Thanks. Sorry about the doc's...I really should add that language id info to it.

As far as character encoding, maybe i can add some kinda flag that the crex_read.php script can pick up...to allow stuff to be spit out in a particular character encoding.

The CDATA is there just to keep stuff from being parsed...when it isnt supposed to (such as HTML text for products or what not)

Link to comment
Share on other sites

Hi again.

 

I need an function that returns id, name and path of any subcategories in a given category as XML, and I can't get it to work. :blush:

 

I could not find any such function among the OsC functions either.

 

Any chance you could whip up something easily?

 

Cheers,

 

Andreas

Link to comment
Share on other sites

Nvm, i got it now.

 

Here it is if anyone else needs it.

 

	function crex_get_subcategories_xml($category,$args=array('language_id'=>'1')) {
	$sql_subcat_result = tep_db_query("select c.categories_id, cd.categories_name from ".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION." cd where c.parent_id = '".$category."' and cd.categories_id = c.categories_id and cd.language_id='" . (int)$args['language_id'] ."' order by c.sort_order, cd.categories_name");
	$count_subcats= tep_db_num_rows($sql_subcat_result);  
  		while ($count_subcats) {
		$subcats = tep_db_fetch_array($sql_subcat_result);
			if (!empty($subcats)){
			$subcats['cpath'] = tep_href_link(FILENAME_DEFAULT, 'cPath=' . $category . '_' . $subcats['categories_id']);
			$return_value .= crex_xml_data_node(html_entity_decode(crex_xml_from_array($subcats)));
			}
		$count_subcats--;
	}

	return $return_value;
}

Link to comment
Share on other sites

  • 3 weeks later...

*** UPDATE ***

 

HERE is a complete list of commands, along with their flags:

 

------------

0 - crex_read.php?cmd=
user_login

&email_address=[users email]

&password=[password]&action=process

(note, "action=process" flag is mandatory)

 

1 - crex_read.php?cmd=
user_logout

 

2 - crex_read.php?cmd=
user_register

&gender=[m
or
f]&firstname=[first name]

&lastname=[last name]

&dob=[date of birth "mm/dd/yyyy" format
(if enabled)
]

&email_address=

---------------

 

TIP: adding the "language_id=[numeric language id of your language]" will cause the output to be spit out using the text your osCommerce store has stored for that language.

Edited by redpiersystems
Link to comment
Share on other sites

Forgot to mention...ALL COMMANDS RETURN XML. ;)

 

A CRELoaded B2B specific version of CREX is in the works, which will be available for a fee from a partner soon. More details will be posted here, too.

 

Custom development of CREX, or mods using CREX are also available from me for a fee (i gotta eat too ya know ;) )

 

Feel free to mod as you like, as CREX is GPL.

Edited by redpiersystems
Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

This sounds like what I need to access the shopping cart on a remote site, but I haven't a clue on how to go about using this. Could someone post a quick example of how to use this contribution, what code do I need for the remote site to access one of the crex commands and how to process what it returns. If I had a really simple example I can probably take it from there.

 

Thanks

Link to comment
Share on other sites

Hi,

 

This sounds like what I need to access the shopping cart on a remote site, but I haven't a clue on how to go about using this. Could someone post a quick example of how to use this contribution, what code do I need for the remote site to access one of the crex commands and how to process what it returns. If I had a really simple example I can probably take it from there.

 

Thanks

 

if the shopping cart has the crex mod, and they have made it publicly readable (permissions, etc...), then you should be able to retrieve categories/products using the "get_categories" (returns first 2 levels of categories), "get_all_categories" (retrieves all categories, requires a recursive function to read), "get_product", ...and view items in your own shopping cart with the "retrieve_cart" command

 

View the list of commands for a complete list.

Link to comment
Share on other sites

*** SNIPPET: FOR PHP scripts that want to use XML documents generated by CREX ***

 

Use an XMLDOM of your choice in php, if that is what you want. I have also provided an XMLDOM class that can be included in other php scripts for everyone's convenience. It is available here:

 

https://sourceforge.net/projects/mypxl/

 

STEP 1: Upload "mypxl.php" anywhere you want

STEP 2: Include it in your php script, use the following to load an XML document:

 

<?php

// Include the myPXL XMLDOM library (includes CREX functions)
include('mypxl.php');

// Create our XMLDOM object

$xmlTheDocument = new XMLDOM();

// Load the URL

$xmlTheDocument->parse('http://www.SomeSite.com/crex_read.php?cmd=get_categories');

// ...(if you already have XML in a string variable, you can just use the parse_string() method):
// $xmlTheDocument->parse_string($The_XML_String_or_Something);

// ...Access any part of the output as an array. The following
// prints out the whole array for you to view in your browser:
// (Uncomment the next line to view)
//print_r($xmlTheDocument->output);

// ... You can use a foreach() loop to go through all <data> nodes:

foreach($xmlTheDocument->output[0]['child'] as $data_index => $data_node){
  // Get attributes if you want them:
  $categories_id = $data_node['attrs']['CPATH'];
  $has_subcategories = $data_node['attrs']['HAS_SUBCATEGORIES'];
  $product_count = $data_node['attrs']['PRODUCT_COUNT'];
  $parent_id = $data_node['attrs']['PARENT'];
  $category_text = $data_node['content'];

  echo "[This is category item '$category_text', its category id is #$categories_id, and it has $product_count total products.]";
}
?>

 

...Enjoy! and remember, donations will go a long way to making CREX a more awesome contrib. So donate if you can. Thanks!

Edited by redpiersystems
Link to comment
Share on other sites

Hello,

 

I have gotten the get_product and get_cartegories xml file to work on the external site. I am able to retrieve the information and display it, which is great.

 

But I can not get the retrieve_cart command to work when called on the external site. When I try executing the retrieve_cart command in my browser, it comes back with the contents of my cart, but when I use it in my external site, it always comes back with the cart being empty. I believe that it is probably has something to do with the wrong cookie being used, but I don't know for sure and don't know what to do to fix it. The commands to retrieve products and categories don't require any session or identification information whereas the retrieve_cart will. Any suggestions would be very helpful.

 

Here is how I have the sessions configured:

Session Directory /tmp

Force Cookie Use True

Check SSL Session ID True

Check User Agent False

Check IP Address False

Prevent Spider Sessions True

Recreate Session True

 

Thanks for your help.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...