How to order Excel Export multi Worksheet XML - magento

The Magento orders Export mechanism built-in does not export goods orders
I would like to ask you how to export each order on a Worksheet Worksheet within each piece of data is a commodity information
The following are examples
<Workbook>
<Worksheet ss:Name="order1">
<Table>
<Row>
<Cell><Data ss:Type="String">Order #</Data></Cell>
<Cell><Data ss:Type="String">SKU</Data></Cell>
<Cell><Data ss:Type="String">Qty</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number">1</Data></Cell>
<Cell><Data ss:Type="String">A1</Data></Cell>
<Cell><Data ss:Type="Number">3</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number">1</Data></Cell>
<Cell><Data ss:Type="String">A2</Data></Cell>
<Cell><Data ss:Type="Number">5</Data></Cell>
</Row>
</Table>
</Worksheet>
<Worksheet ss:Name="order2">
<Table>
<Row>
<Cell><Data ss:Type="String">Order #</Data></Cell>
<Cell><Data ss:Type="String">SKU</Data></Cell>
<Cell><Data ss:Type="String">Qty</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number">2</Data></Cell>
<Cell><Data ss:Type="String">B1</Data></Cell>
<Cell><Data ss:Type="Number">2</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number">2</Data></Cell>
<Cell><Data ss:Type="String">B2</Data></Cell>
<Cell><Data ss:Type="Number">3</Data></Cell>
</Row>
</Table>
</Worksheet>
Through the the understanding lib/Varien/Convert/Parser/Xml/Excel.php, Magento itself does not support multi Worksheet Export
I plan to write another one Parser, do multi-Worksheet Export.
But the bigger issue, export the data needs through
app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php the _prepareColumns () processing
But I can not find how to call database
I hope we can help, thank you

You can drop the PHPExcel library in 'lib' and Magento will autoload it without further ado in your module (You'll be needing a custom module).
Since you are writing rather than reading you should be able to work with PHPExcel within your existing memory (importing with PHPExcel can be huge).
There are no limits on what you can do with the fine control of PHPExcel, obviously you'll need to iterate your orders too and your module will need a back end.
You can put together a skeleton module, see if you can create a EXcel file (pop some of the demo code in and see if it picks up the classes etc). Then you should be able to export great reports once you have those bits working.
http://phpexcel.codeplex.com/
https://stackoverflow.com/a/4816738/1617149

Related

How to design conditional content control using OpenDoPE add-in

Iam using OpenDoPE add-in(First/Old version), I have a table design like follows
I have an xml data like follows
<myxml>
<rows>
<row>
<name>Abhilash Shajan</name>
<company>Standout</company>
<designation>Developer</designation>
<age>20</age>
</row>
<row>
<name>Sam Thomas</name>
<company>Allianze</company>
<designation>Tester</designation>
<age>27</age>
</row>
<row>
<name>Pradhap</name>
<company>UST</company>
<designation>SQL developer</designation>
<age>26</age>
</row>
<row>
<name>Ragesh</name>
<company>IBS</company>
<designation>Tester</designation>
<age>22</age>
</row>
</rows>
</myxml>
I need to apply condition to my repeating content control(here the row node is the repeating content control). Here is my condition, If age is greater than 25 then that row should not be visible.
How to write this condition in my OpenDoPE task pane.
Iam a beginner to this add-in can someone help me?
The conditional content control should be wrapped around (ie contain) the row, and the repeat content control should be wrapped around the conditional content control.
You might find it easier to first add the conditional content control, then add the repeat content control.

xpath internal link parsing

I have got a soap response from a webservice where it looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Body>
<multiref id="1">
<cpuclock>2300</cpuclock>
<memoryComponent>
<item href="#2"/>
<item href="#3"/>
</memoryComponent>
</multiref>
<multiref id="2" type="ns2:MemoryComponent">
<type>RAM</type>
<quantity>2048</quantity>
</multiref>
<multiref id="3" type="ns3:MemoryComponent">
<type>RAM</type>
<quantity>1024</quantity>
</multiref>
</Body>
What I am trying to achieve is to recover the memoryComponent elements.
Since I am using the XMLUtil of VBScript/QTP, I've been trying to workaround using XPATH (by predicates). Ends-with is not supported by my QTP framework version.
Any suggestions?
TIA!
I've found a way to retrieve the elements I wanted.
Set childElements = XMLFile.ChildElementsByPath("/Body/multiref[contains(#type,'MemoryComponent')]")
This workaround suits my needs pretty well.
Thanks!

XPATH exclude more than one element/tag

I am having issues trying to extract text between two div tags in an XML.
Imagine I have the following XML:
<div class="default_style_wrap" >
<!-- Body starts -->
<!-- Irrelvent Data -->
<div style="clear:both" />
<!-- Irrelvent Data -->
<div class="name_address" >...</div>
<!-- Irrelvent Data -->
<div style="clear:both" />
<!-- Irrelvent Data -->
<span class="img_comments_right" >...</span>
<!-- Text that I want to get -->
Two members of the Expedition 35 crew wrapped up a 6-hour, 38 minute spacewalk at 4:41 p.m. EDT Friday to deploy and retrieve several science experiments on the exterior of the International Space Station and install a new navigational aid.
<br />
<br />
The spacewalkers' first task was to install the Obstanovka experiment on the station's Zvezda service module. Obstanovka will study plasma waves and the effect of space weather on Earth's ionosphere.
<!-- Irrelvent Data Again -->
<span class="img_comments_right" >...</span>
<!-- Text that I want to get -->
After deploying a pair of sensor booms for Obstanovka, Vinogradov and Romanenko retrieved the Biorisk experiment from the exterior of Pirs. The Biorisk experiment studied the effect of microbes on spacecraft structures.
<br />
<br />
This was the 167th spacewalk in support of space station assembly and maintenance, totaling 1,055 hours, 39 minutes. Vinogradov's seven spacewalks total 38 hours, 25 minutes. Romanenko completed his first spacewalk.
<!-- Body ends -->
</div>
As it may not be reflective in the code, default_style_wrap is the parent of all those other irrelevant divs and spans. The relevant text to me is basically all of the tag-less text but as there are other tags in between as you can see, for instance img_comments_right, it is driving me nuts.
I tried the following as I saw in another post:
"//div[#class='article_container']/*[not(self::div)]";
but that seems not be returning any text at all, and even if it did, I wouldn't know how to also exclude the spans.
Any ideas?
Solution:
You can use or operator for specifying multiple conditions for not operator
Like so:
not(expr1 or expr2)
Thus you can add self::span as another condition for not to exclude them from result ;
//div[#class='default_style_wrap']/*[not(self::div or self::span)]
PS: There seems to be issue with improper closing of div tags. Close them in a proper way.
You should try the following query. It selects all following siblings of the <span> nodes, which are text nodes:
query = '//span[#class="img_comments_right"]/following-sibling::text()';
You can use this xpath:
//div[#class='default_style_wrap']/text()
You should be able to grab the text, using this XPath:
div[#class = 'default_style_wrap']/text()[normalize-space()]
It selects all text() nodes that are children of the *default_style_wrap* <div>, filtering empty (or whitespace-only) nodes out.
If you use a separate template, you can put each chunk neatly in its own paragraph, e.g.:
<xsl:template match="/">
<xsl:apply-templates select="div[#class = 'default_style_wrap']/text()[normalize-space()]" />
</xsl:template>
<xsl:template match="text()">
<p><xsl:value-of select="." /></p>
</xsl:template>

XSLT to display news item images with consistent size

I have a RSS XML news file, which contains a list of items inclusive of a URL to an image. I also have an associated XSLT.
The problem is that the image sizes are not consistent and I want to limit the image sizes, resize them, to a nice thumbnail.
How would I modify the XSLT to accomplish that?
XML Sample:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version ="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>Company Name</title>
<description>Company description</description>
<link>http://www.mycompanyurl.com</link>
<item>
<title>News Item Title</title>
<link>http://www.whateverurl.com/</link>
<category>Space</category>
<pubDate>12 April 1961</pubDate>
<description>Software to reduce your job search to a half hour per day. all major job sites, job boards, classifieds. unemployment paperwork, CRM, interviews, more</description>
<image>
<url>~/App_Data/NewsControl/whatever.png</url>
<title>Whatever1</title>
<link>javascript:void(0)</link>
</image>
<g:id>1</g:id>
<g:brand>Whatever2</g:brand>
<g:condition>whatever3</g:condition>
<g:price>$whatever4</g:price>
<g:product_type>Whatever5</g:product_type>
</item>
</channel>
</rss>
Here is the associated XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<items>
<xsl:for-each select="//item">
<item Name="{position()}" HeaderText="{title}" Text="{description}" NavigateUrl="{position()}" Date="{pubDate}" ImageUrl="{image/url}"/>
</xsl:for-each>
</items>
</xsl:template>
</xsl:stylesheet>
Results of First Answer:
<items>
<xsl:for-each select="//item">
<item Name="{position()}" HeaderText="{title}" Text="{description}" NavigateUrl="{position()}" Date="{pubDate}" ImageUrl="/Tools/thumber.php?img={image/url}"/>
</xsl:for-each>
</items>
I made these changes, enabled PHP on the server (testing on from the server and locally), and saw 2 issues:
1. I get no image, merely a no image box.
If I try to edit the ImageUrl and tack on a "&W=xxx&H=xxx", the Visual Studio validator complains and throws up errors on the &.
Update 2
Here is the latest line in the XSLT:
http://myserver.com/Tools/thumber.php?img=',image/url)}"/>
The corresponding image section in the XML
<image>
<url>/Products/Jobfish/Images/Boxshots/Jobfish_DVDCaseCD_ShadowOut.jpg</url>
<title>Jobfish</title>
<link>javascript:void(0)</link>
XSLT has no built in function for resizing or thumbnailing. You will have to use an external processor for that eg. by using a PHP thumbnail generator.
Then replace the original image path with a URL pointing to your thumbnail generator, with the source being the original image.
suppose ImageUrl = mediaserver.xyz/ourlogo.jpg
the new ImageUrl would become myserver.com/thumbnailgenerator.php?src=http://mediaserver.xyz/ourlogo.jpg
Please make shure you select a caching thumbnail library (eg https://code.google.com/p/phpthumbmaker/wiki/ThumberWiki ) , since it will be a serious resource hog if you skip that. Also take into account copyright issues when re-serving these thumbnails.

Joomla component not appearing in the menu item types

I just followed the joomla tutorials on how to create the "perfect" MVC joomla component. However, my problem is that I don't know yet how to assign it to a menu. I thought that my component would then just show up when I select a "menu item type", but my component is not on this list. I've made some research on Google, but I cannot find the answer... Do I have to create a metadata.xml file or something similar ?
Thanks in advance for your answers !!
To create "views" for your component, you have to create some xml files.
Inside the templates folder in the frontend part of your component (usually something like /components/com_yourcomponent/views/someview/tmpl), if you had a template named default.php and form.php, you can create a default.xml file and a form.xml file to make these menu items available from the administrator.
You can take a look at other components to see the structure of these xml files, but what you should put inside is:
1) A name and a description for four view
2) The params the user will be able to change from the administrator (it works like module/plugin params)
3) You can also set "hidden" request variables for that menu item. It means that those vars will be added to the request in that particular menu item, but the user won't be able to change its value.
Here's a complete example for a component (Joomla 1.7):
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_AGMTAGS_TAG_VIEW_DEFAULT_TITLE">
<message>COM_AGMTAGS_TAG_VIEW_DEFAULT_DESC</message>
</layout>
<fields name="request" addfieldpath="/administrator/components/com_agmtags/models/fields">
<fieldset name="request">
<field name="tag_id" type="agmtag"
label="COM_AGMTAGS_TAG_FIELD_NAME_LABEL"
description="COM_AGMTAGS_TAG_FIELD_NAME_DESC"
/>
</fieldset>
</fields>
<fields name="params">
<fieldset name="basic" label="COM_AGMTAGS_TAG_OPTIONS">
<field name="layout_type" type="hidden" default="blog" />
<field name="show_tag_name" type="list"
label="COM_AGMTAGS_SHOW_TAG_NAME"
description="COM_AGMTAGS_SHOW_TAG_NAME_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_tag_description" type="list"
description="COM_AGMTAGS_SHOW_TAG_DESCRIPTION_DESC"
label="COM_AGMTAGS_SHOW_TAG_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="items_per_page" type="text" default="" />
<field name="container_class" type="text" default="agmtags-list" />
</fieldset>
</fields>
</metadata>
I hope it helped!
If you simply want to add the view link to the list create a xml file called default.xml inside the com_yourcomponent/views/yourviewname/tmpl/
The xml code below takes two language strings used to display your menu item link in the list
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_YOURCOMPONENT_FRONPAGE_TITLE">
<message>COM_YOURCOMPONENT_FRONPAGE_MSG</message>
</layout>
</metadata>
save the file and the link should appear in the list of menu items
Apparently, you also need the administration menu tags in your installation XML file.
http://forum.joomla.org/viewtopic.php?p=706714
This worked for me
<administration>
<menu>COM_COMPONET</menu>
<submenu>
etc...
</submenu>
Think this is what Panayiotis was trying to say
Additionally there is also another catch.
In the installation XML file of the component,
in the section, the tags must
be present, even if you do not need the menu.
If these are missing, then you'll never be given
the option to add this component to a menu item,
because the type wont be there :-)
In additional, your alternative view file names MUST NOT be written with underscores.
table_catalog.xml
table_catalog.php
table_catalog_item.php
didn't work - there wasn't new option in "menu item type" list. But
tablecatalog.xml
tablecatalog.php
tablecatalog_item.php
file names work perfectly. I've lost an hour revealing a problem.

Resources