Login

 

How to export SOBI2 Business Index information to Excel PDF Print E-mail
Written by Joomla-R-Us   
Tuesday, 18 August 2009 01:37

sobi2SOBI2 (Sigsiu Online Business Index 2) allows you to configure custom fields for entries. It's very hard to write a generic SQL query which exports these custom fields that you might have. The sample report that you can download for SOBI2 has been defined for the default fields. This Tutorial will tell you how to export custom SOBI2 data into an Excel spreadsheet with SQL 2 Excel.

 

  1. Download and install SQL 2 Excel component, if you haven't done that already.

  2. Download and install the SOBI2 sample report.

    Installation Instructions

  3. The Sample Report has been configured for the default profile fields in SOBI2. If you have added or removed some fields then you will need to modify the SQL query from the Sample Report to match your configuration. Follow the steps below to customize the report.

  4. For this tutorial, I installed SOBI2 RC 2.9.2.2 and added just one new custom field called "field_hives" in the Custom Fields Manager.

    sobi_custom_fields_sm
    Image 1

  5. The field data is stored in a database table called jos_sobi2_fields_data:

    sobi_fields_data_sm
    Image 2

  6. If you look at the content of the jos_sobi2_fields_data table you will see all  the fields that you have defined in the "Custom Profile" screen in the Custom Fields Manager. There is one entry per field and item.  Note the fieldid which is the Field ID's. You can see the field ID tin the rightmost column inside the Custom Fields Manager screen in SOBI2. Or you can look in the jos_sobi2_language table and locate the field names and ID's. Use phpMyAdmin or something similar to examine the content of your database. Most ISP's provide you with phpMyAdmin through the control panel of your website.

    You may have added some new fields, deleted or unpublished some fields. The sample SOBI2 report that you can download is written for the default fields. In this tutorial I have added one field called "field_hives". In the Custom Fields Managers screen (image 1) we can see that the field ID is 16 for this field.


  7. Go to SQL 2 Excel > Worksheets in the Administrator interface and locate the SOBI2 - Items Worksheet.

    sobi2_ws_sm

  8. Click on the title to edit the Worksheet.


  9. The SQL Query is defined like this:
    SELECT a.itemid as `ID`, 
    a.title as `Title`,
    GROUP_CONCAT(DISTINCT e.name ORDER BY e.name) AS `Categories`,
    GROUP_CONCAT(DISTINCT e.catid ORDER BY e.name) AS `Category IDs`,
    a.hits as `Hits`,
    a.visits as `Visits`,
    b.name as `Owner Name`,
    b.email as `Owner Email`,
    MAX(IF(c.fieldid=1,c.data_txt, NULL)) as `Street`,
    MAX(IF(c.fieldid=2,c.data_txt, NULL)) as `Postcode`,
    MAX(IF(c.fieldid=3,c.data_txt, NULL)) as `City`,
    MAX(IF(c.fieldid=4,c.data_txt, NULL)) as `County`,
    MAX(IF(c.fieldid=5,c.data_txt, NULL)) as `Federal State`,
    MAX(IF(c.fieldid=6,c.data_txt, NULL)) as `Country`,
    MAX(IF(c.fieldid=7,c.data_txt, NULL)) as `Email`,
    MAX(IF(c.fieldid=8,c.data_txt, NULL)) as `Website`,
    MAX(IF(c.fieldid=9,c.data_txt, NULL)) as `Contact Person`,
    MAX(IF(c.fieldid=10,c.data_txt, NULL)) as `Phone`,
    MAX(IF(c.fieldid=11,c.data_txt, NULL)) as `Fax`,
    MAX(IF(c.fieldid=12,c.data_txt, NULL)) as `Hotline`,
    MAX(IF(c.fieldid=13,c.data_txt, NULL)) as `Description`
    FROM #__sobi2_item a
    LEFT JOIN #__users b ON a.owner = b.id
    LEFT JOIN #__sobi2_fields_data c on c.itemid=a.itemid
    LEFT JOIN #__sobi2_cat_items_relations d on d.itemid=a.itemid
    LEFT JOIN #__sobi2_categories e ON e.catid=d.catid
    WHERE d.itemid=a.itemid
    GROUP BY a.itemid
    ORDER BY ID DESC
  10. If you have deleted or unpublished some fields then you have to remove them from the query. In this case we just want to add one new custom field to the report,  "field_hives" / Hives Fan field.  In the Custom Fields Manager we can see that the field_hives field has the ID=16 We just need to add one new line to the query to add this field, like this:
    SELECT a.itemid as `ID`, 
    a.title as `Title`,
    GROUP_CONCAT(DISTINCT e.name ORDER BY e.name) AS `Categories`,
    GROUP_CONCAT(DISTINCT e.catid ORDER BY e.name) AS `Category IDs`,
    a.hits as `Hits`,
    a.visits as `Visits`,
    b.name as `Owner Name`,
    b.email as `Owner Email`,
    MAX(IF(c.fieldid=1,c.data_txt, NULL)) as `Street`,
    MAX(IF(c.fieldid=2,c.data_txt, NULL)) as `Postcode`,
    MAX(IF(c.fieldid=3,c.data_txt, NULL)) as `City`,
    MAX(IF(c.fieldid=4,c.data_txt, NULL)) as `County`,
    MAX(IF(c.fieldid=5,c.data_txt, NULL)) as `Federal State`,
    MAX(IF(c.fieldid=6,c.data_txt, NULL)) as `Country`,
    MAX(IF(c.fieldid=7,c.data_txt, NULL)) as `Email`,
    MAX(IF(c.fieldid=8,c.data_txt, NULL)) as `Website`,
    MAX(IF(c.fieldid=9,c.data_txt, NULL)) as `Contact Person`,
    MAX(IF(c.fieldid=10,c.data_txt, NULL)) as `Phone`,
    MAX(IF(c.fieldid=11,c.data_txt, NULL)) as `Fax`,
    MAX(IF(c.fieldid=12,c.data_txt, NULL)) as `Hotline`,
    MAX(IF(c.fieldid=13,c.data_txt, NULL)) as `Description`,
    MAX(IF(c.fieldid=16,c.data_txt, NULL)) as `Hives Fan`
    FROM #__sobi2_item a
    LEFT JOIN #__users b ON a.owner = b.id
    LEFT JOIN #__sobi2_fields_data c on c.itemid=a.itemid
    LEFT JOIN #__sobi2_cat_items_relations d on d.itemid=a.itemid
    LEFT JOIN #__sobi2_categories e ON e.catid=d.catid
    WHERE d.itemid=a.itemid
    GROUP BY a.itemid
    ORDER BY ID DESC

    If you have deleted or unpublished any of the default fields, just remove them from the Sample Query.

  11. Save the Worksheet, then try to download the SOBI2 Workbook in SQL 2 Excel.

  12. You may need to adjust column widths to fit your custom field information. The column widths are specified as a comma delimited string:

    sobi2_colwidths

    Add/remove/edit values as needed to make your spreadsheet look nice.

    Please note that the screenshot is from SQL 2 Excel Pro which has a few more controls, but the Column Widths are settable in the free version as well.




 

 

Comments (4)add comment

Wikus said:

0
...
Hi there,

Thank you for this component. It might be exactly what I am looking for.

I have one question though, is it possible to extract all the listings/data from a specific category in Sobi2?

I have a category named "Cape Town" for example. Is it possible to only get the data belonging to that category?
 
July 20, 2010
Votes: +0

Mats @ Joomla-R-Us said:

admin
...
@Wikus: You can easily filter the info for one or more categories. Just add the category filter in the WHERE clause. Example:

SELECT a.itemid as `ID`,
a.title as `Title`,
GROUP_CONCAT(DISTINCT e.name ORDER BY e.name) AS `Categories`,
GROUP_CONCAT(DISTINCT e.catid ORDER BY e.name) AS `Category IDs`,
a.hits as `Hits`,
a.visits as `Visits`,
b.name as `Owner Name`,
b.email as `Owner Email`,
MAX(IF(c.fieldid=1,c.data_txt, NULL)) as `Street`,
MAX(IF(c.fieldid=2,c.data_txt, NULL)) as `Postcode`,
MAX(IF(c.fieldid=3,c.data_txt, NULL)) as `City`,
MAX(IF(c.fieldid=4,c.data_txt, NULL)) as `County`,
MAX(IF(c.fieldid=5,c.data_txt, NULL)) as `Federal State`,
MAX(IF(c.fieldid=6,c.data_txt, NULL)) as `Country`,
MAX(IF(c.fieldid=7,c.data_txt, NULL)) as `Email`,
MAX(IF(c.fieldid=8,c.data_txt, NULL)) as `Website`,
MAX(IF(c.fieldid=9,c.data_txt, NULL)) as `Contact Person`,
MAX(IF(c.fieldid=10,c.data_txt, NULL)) as `Phone`,
MAX(IF(c.fieldid=11,c.data_txt, NULL)) as `Fax`,
MAX(IF(c.fieldid=12,c.data_txt, NULL)) as `Hotline`,
MAX(IF(c.fieldid=13,c.data_txt, NULL)) as `Description`
FROM jos_sobi2_item a
LEFT JOIN jos_users b ON a.owner = b.id
LEFT JOIN jos_sobi2_fields_data c on c.itemid=a.itemid
LEFT JOIN jos_sobi2_cat_items_relations d on d.itemid=a.itemid
LEFT JOIN jos_sobi2_categories e ON e.catid=d.catid
WHERE d.itemid=a.itemid AND e.name='Cape Town'
GROUP BY a.itemid
ORDER BY ID DESC
 
July 20, 2010
Votes: +1

danny said:

danny
...
Thank you this helped me out big time!
Danny diaper coupons
 
June 23, 2011
Votes: +0

fvtoco said:

fvtoco
...
I do like to show all categories. in my case are 3 categories; state, county and parish in which only show the parish GROUP_CONCAT clause
 
November 15, 2011
Votes: +0

Write comment
You must be logged in to post a comment. Please register if you do not have an account yet.

busy
Last Updated on Thursday, 27 August 2009 19:37
 
 
 
  Design by augs-burg.de & go-vista.de  
 
     
 
   
 

The Joomla!(R) name is used under a limited license from Open Source Matters in the United States and other countries. http://Joomla-R-Us.com is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.