OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: Heads Up: Crex Oscommerce Xml
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Contributions / Add-Ons > Contribution Development
redpiersystems
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!
redpiersystems
... 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!
redpiersystems
******** 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...) biggrin.gif

As usually, constructive comments, questions... are always welcome!
redpiersystems
By the way... there are two (2) places to download from:

http://www.oscommerce.com/community/contributions,5198

...and ...

http://sourceforge.net/projects/crex/
giannimoto
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
Get-Wireless 2
Would this allow me to import a stock quantity and price for various products from a supplier?
The format they send out in is
CODE
<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
MattGSX
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?
redpiersystems
QUOTE (giannimoto @ Aug 14 2007, 12:46 AM) *
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
redpiersystems
QUOTE (Get-Wireless 2 @ Aug 14 2007, 01:23 PM) *
Would this allow me to import a stock quantity and price for various products from a supplier?
The format they send out in is
CODE
<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
MattGSX
QUOTE (redpiersystems @ Aug 20 2007, 01:27 PM) *
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.
athyholdt
QUOTE (giannimoto @ Aug 14 2007, 09:46 AM) *
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:

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


to:

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


I hope this helps.

Cheers,

Andreas
athyholdt
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:

CODE
$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:

CODE
$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
redpiersystems
QUOTE (athyholdt @ Aug 24 2007, 10:48 AM) *
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:

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


to:

CODE
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.
athyholdt
QUOTE (redpiersystems @ Aug 25 2007, 10:31 AM) *
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 wink.gif

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 wink.gif 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
redpiersystems
QUOTE (athyholdt @ Aug 25 2007, 03:46 AM) *
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 wink.gif

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 wink.gif 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)
athyholdt
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.gif

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

Any chance you could whip up something easily?

Cheers,

Andreas
athyholdt
Nvm, i got it now.

Here it is if anyone else needs it.

CODE
    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;
    }
redpiersystems
*** 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=[email address]
&company=[name of company (optional)]
&street_address=[street address]
&suburb=[suburb (if enabled)]
&postcode=[some zip code]
&city=[city name]
&state=[state (if enabled)]
&zone_id=[numeric zone id (if state is enabled, and state has zone ids; optional)]
&country=[numeric country id]
&telephone=[telephone number]
&fax=[fax number]
&newsletter=[true or false; (optional)]
&password=[password]
&confirmation=[password re-typed]


3 - crex_read.php?cmd=product_add_to_cart
&products_id=[numeric product id]
&qty=[numeric quantity]
&attributes=[attributes (I have no idea how osC manages this one; optional)]
&notify=[true or false (optional)]


4 - crex_read.php?cmd=product_update_quantity
&products_id=[numeric product id]
&qty=[numeric quantity]
&attributes=[attributes (I have no idea how osC manages this one; optional)]


5 - crex_read.php?cmd=product_remove_from_cart
&products_id=[numeric product id]


6 - crex_read.php?cmd=retrieve_cart

7 - crex_read.php?cmd=product_delete_cart

8 - crex_read.php?cmd=product_search
&keywords=[text to search for]
&dfrom=[date from in "mm/dd/yyyy" format (optional)]
&dto=[date to in "mm/dd/yyyy" format (optional)]
&pfrom=[numeric price from (optional)]
&pto=[numeric price to (optional)]


9 - crex_read.php?cmd=get_categories

10 - crex_read.php?cmd=get_category_products
&cpath=[numeric category id]


11 - crex_read.php?cmd=get_category_product_count
&cpath=[numeric category id]


12 - crex_read.php?cmd=get_product
&pid=[numeric product id]


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

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.
redpiersystems
Forgot to mention...ALL COMMANDS RETURN XML. wink.gif

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 wink.gif )

Feel free to mod as you like, as CREX is GPL.
redpiersystems
**** UPDATE: myPXL (generic non-osc specific crex.php function library) released ***

If you need the crex.php functions, along with an XMLDOM class, then checkout mypxl.

There are 2 locations for download:

http://sourceforge.net/project/showfiles.php?group_id=206427

and here:

http://www.oscommerce.com/community/contributions,5198/
redpiersystems
**** UPDATE: Release 0004 is now out! ****

Includes: Support for product attributes, and complete category listing (view CHANGE LOG.txt and README-commands.txt for more info)

Remember to donate if you can!


-Enjoy

LINK 1: http://addons.oscommerce.com/info/5198
LINK 2: https://sourceforge.net/project/platformdow...l_platform=2426
ljk
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
redpiersystems
QUOTE (ljk @ Oct 11 2007, 12:09 PM) *
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.
redpiersystems
*** 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:

CODE
<?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!
ljk
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.
redpiersystems
The script uses osCommerce's built in session handling ...it does not do any session handling of its own.

It could be that it works as such for security reasons. However, if more people think adding session preservation as an option is a good idea, then it can be added. (For now, its not "fixed" for security reasons)

...In any case, I am still trying to figure something out that would work in a safe manner. Any body have any hints?

QUOTE (ljk @ Oct 14 2007, 08:57 PM) *
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.
athyholdt
QUOTE (redpiersystems @ Oct 15 2007, 09:00 AM) *
It could be that it works as such for security reasons. However, if more people think adding session preservation as an option is a good idea, then it can be added. (For now, its not "fixed" for security reasons)


I would welcome a way to preserve the OsC session outside the cart. I am having the same issue, ie. I lose the session when I call the script externally.

Cheers,

Andreas
redpiersystems
..Anybody have any ideas on how this should be accomplished... (maybe the osc session functions have this built in???)
redpiersystems
Meh, I cant think of another way without using a session token based system. The bad part about such a system is that it would be very exposed to session stealing.

Guess I wont add it myself...but if someone else decides to...go for it. tongue.gif

QUOTE (redpiersystems @ Oct 18 2007, 02:09 AM) *
..Anybody have any ideas on how this should be accomplished... (maybe the osc session functions have this built in???)
redpiersystems
Hi guys, just checking in to see how everything is going. I'd like to know if this mod has met at least some of your needs, and if you have found it easy to use.

Also, i'd like to know what your thoughts are on how its laid out, what can be done to make things easiers, ...etc ...etc...

Thanks!
redpiersystems
*** NEWS: January 2 2008 ***

CREX version 5 is in the works:

Includes the following:


- The "get_category_products" command will now retrieve more information per product (url, image, price, and some other fields...but not description).
- Minor bug fixes ("get_all_categories" command was not retrieving cpath attributes correctly).
- A few more implemented features.
- And more!


Thanks for your donation(s) .... Remember folks, all donations go towards making CREX - osCommerce XML that much more awesome!
(View the SourceForge.net/crex page to view donation info)
heavyg
QUOTE (redpiersystems @ Jan 3 2008, 02:31 AM) *
*** NEWS: January 2 2008 ***

CREX version 5 is in the works:

Includes the following:
- The "get_category_products" command will now retrieve more information per product (url, image, price, and some other fields...but not description).
- Minor bug fixes ("get_all_categories" command was not retrieving cpath attributes correctly).
- A few more implemented features.
- And more!
Thanks for your donation(s) .... Remember folks, all donations go towards making CREX - osCommerce XML that much more awesome!
(View the SourceForge.net/crex page to view donation info)


This mod looks like it has the flexibility we've been looking for to solve a problem we've been struggling with. We need to create a "custom" landing page on a OSC site that would have a button and a few text fields on it. One text field would prompt the user for a part number, they would then press the button to run a script to retrieve the part details on a third party site. We then need to create this "on the fly item" and add it to the cart. Does this sound like something your mod would be good for ? Any tips on the approach ?
Thanks in advance!
zeeshop
Hi,

is there any thing you done regarding importing Product stock in catelog using XML, as discuss3ed earlier in this forum.



Regards
redpiersystems
QUOTE (heavyg @ Jan 24 2008, 05:38 AM) *
This mod looks like it has the flexibility we've been looking for to solve a problem we've been struggling with. We need to create a "custom" landing page on a OSC site that would have a button and a few text fields on it. One text field would prompt the user for a part number, they would then press the button to run a script to retrieve the part details on a third party site. We then need to create this "on the fly item" and add it to the cart. Does this sound like something your mod would be good for ? Any tips on the approach ?
Thanks in advance!


I believe so. You should be able to use one or more of the commands listed to retrieve a search query for that part (it uses a copy of the oscommerce search code).

The search will return XML containing the product(s) returned.

CREX also allows you to add said item to your cart.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.