What does the "update" element do in Magento layout XML? - layout

Right now I'm exploring the internals of the admin section of Magento and I stumbled on this piece of XML:
File: app/design/adminhtml/default/default/layout/catalog.xml, around line 55
50 <block type="core/template" template="catalog/wysiwyg/js.phtml"/>
51 </reference>
52 </adminhtml_catalog_product_new>
53
54 <adminhtml_catalog_product_edit>
55 <update handle="editor"/>
56 <reference name="content">
57 <block type="adminhtml/catalog_product_edit" name="product_edit"></block>
58 </reference>
What does the <update /> tag do?

The <update> basically pulls in another handle.
Assume you have this:
<layout>
<foo>
<reference name="header">
<block type="cms/block" name="some_block" as="someBlock">
<action method="setBlockId"><block_id>some_block</block_id></action>
</block>
</reference>
<reference name="left">
<block type="cms/block" name="some_totally_different_block" as="someTotallyDifferentBlock">
<action method="setBlockId"><block_id>some_totally_different_block</block_id></action>
</block>
</reference>
</foo>
<bar>
<update handle="foo" />
<reference name="header">
<block type="cms/block" name="some_other_block" as="someOtherBlock">
<action method="setBlockId"><block_id>some_other_block</block_id></action>
</block>
</reference>
</bar>
</layout>
The resulting XML for bar would be:
<layout>
<bar>
<reference name="header">
<!-- Start of part pulled in from foo -->
<block type="cms/block" name="some_block" as="someBlock">
<action method="setBlockId"><block_id>some_block</block_id></action>
</block>
<!-- End of part pulled in from foo -->
<block type="cms/block" name="some_other_block" as="someOtherBlock">
<action method="setBlockId"><block_id>some_other_block</block_id></action>
</block>
</reference>
<!-- Start of part pulled in from foo -->
<reference name="left">
<block type="cms/block" name="some_totally_different_block" as="someTotallyDifferentBlock">
<action method="setBlockId"><block_id>some_totally_different_block</block_id></action>
</block>
</reference>
<!-- End of part pulled in from foo -->
</bar>
</layout>
tl;dr: The update handle is basically a "merge this layout with my current layout".

This handle is used for merging existing layout handles to your current layout.
In your example <update handle="editor"/> will add to the <adminhtml_catalog_product_edit> following content:
<editor>
<reference name="head">
<action method="setCanLoadExtJs"><flag>1</flag></action>
<action method="addJs"><script>mage/adminhtml/variables.js</script></action>
<action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>
<action method="addJs"><script>lib/flex.js</script></action>
<action method="addJs"><script>lib/FABridge.js</script></action>
<action method="addJs"><script>mage/adminhtml/flexuploader.js</script></action>
<action method="addJs"><script>mage/adminhtml/browser.js</script></action>
<action method="addJs"><script>prototype/window.js</script></action>
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/magento.css</name></action>
</reference>
</editor>
("editor" handle is defined in app/design/adminhtml/default/default/layout/main.xml)

Related

Blockly how to prevent concatenated blocks from splitting

In my toolbox.xml I have created a custom block by concatenating multiple blocks, something like
<block type="my_custom_type">
<value name="LIST_REQUIRED">
<block type="lists_create_with" inline="true">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="get_variable"/>
</value>
<value name="ADD1">
<block type="get_variable"/>
</value>
<value name="ADD2">
<block type="get_variable"/>
</value>
</block>
</value>
</block>
in this specific case, a list block is united with my_custom_type block.
After an user drags this new block to the workspace, how do I prevent him from removing the "list" block from the original "my_custom_type" block? At the moment he can do that by clicking on the "list" block, which allows him to take that piece separately.
You can set by attributes in block xml for child blocks , you may try like this
<block type="my_custom_type">
<value name="LIST_REQUIRED">
<block type="lists_create_with" inline="true" deletable="false" movable="false">
<mutation items="3"></mutation>
<value name="ADD0">
<block type="get_variable"/>
</value>
<value name="ADD1">
<block type="get_variable"/>
</value>
<value name="ADD2">
<block type="get_variable"/>
</value>
</block>
</value>
</block>

Add start and end attribute to node and edge in gexf file

I have a .gexf file that contains nodes and edges with IDs and labels. I generated this .gexffile from a .gml file using networkx. Here's the code for that:
import networkx as nx
G = nx.read_gml('data/gml/test.gml') # read in gml file as Graph
nx.write_gexf(G, "output/test.gexf") # write to gexf format
The next thing I want to do, is to add a startand end attribute to every node and every edge in my file.
So basically, I want this:
<?xml version='1.0' encoding='utf-8'?>
<gexf version="1.1" xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gexf.net/1.1draft/viz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
<graph defaultedgetype="undirected" mode="static">
<nodes>
<node id="clock" label="clock" />
<node id="beach" label="beach" />
<node id="sun" label="sun" />
<node id="sea" label="sea" />
<node id="sand" label="sand" />
<node id="guitar" label="guitar" />
(...)
</nodes>
<edges>
<edge id="0" source="ice" target="shoe" weight="0.9995600294856769" />
<edge id="1" source="ice" target="toothbrush" weight="0.9992457544219484" />
<edge id="1533" source="snake" target="ant" weight="0.9999144063155566" />
(...)
<edge id="1534" source="mosquito" target="jellyfish" weight="0.9994175606336606" />
<edge id="1535" source="ant" target="star" weight="0.9994226236705537" />
</edges>
</graph>
</gexf>
to look like this (note the dynamicmode and start and end attributes):
<?xml version='1.0' encoding='utf-8'?>
<gexf version="1.1" xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gexf.net/1.1draft/viz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
<graph defaultedgetype="undirected" mode="dynamic">
<nodes>
<node id="clock" label="clock" start="2000-02-20" end="2000-02-22" />
<node id="beach" label="beach" start="2000-02-20" end="2000-02-22" />
<node id="sun" label="sun" start="2000-02-20" end="2000-02-22" />
<node id="sea" label="sea" start="2000-02-20" end="2000-02-22" />
<node id="sand" label="sand" start="2000-02-20" end="2000-02-22" />
<node id="guitar" label="guitar" start="2000-02-20" end="2000-02-22" />
(...)
</nodes>
<edges>
<edge id="0" source="ice" target="shoe" weight="0.9995600294856769" start="2000-02-20" end="2000-02-22" />
<edge id="1" source="ice" target="toothbrush" weight="0.9992457544219484" start="2000-02-20" end="2000-02-22" />
<edge id="1533" source="snake" target="ant" weight="0.9999144063155566" start="2000-02-20" end="2000-02-22" />
(...)
<edge id="1534" source="mosquito" target="jellyfish" weight="0.9994175606336606" start="2000-02-20" end="2000-02-22" />
<edge id="1535" source="ant" target="star" weight="0.9994226236705537" start="2000-02-20" end="2000-02-22" />
</edges>
</graph>
</gexf>
Unfortunately I was not able to find any documentation (neither for networkx nor for pygexf) on how to write a dyamic gexf file and add a startand end attribute to every (already existing) node and edge. Can anyone please help me with this?
UPDATE:
When I use
nx.set_edge_attributes(G, 'start', '2000-02-20')
nx.set_edge_attributes(G, 'end', '2000-02-22')
To set the edge attributes, I get the correct output, e.g.:
<edge id="0" source="great" target="wait" weight="0.998675772419067" start="2000-02-20" end="2000-02-22" />
However, when I do:
nx.set_node_attributes(G, 'start','2000-02-20')
nx.set_node_attributes(G, 'end','2000-02-22')
I get:
<node id="blue" label="blue">
<attvalues>
<attvalue for="0" value="2000-02-20" />
<attvalue for="1" value="2000-02-22" />
</attvalues>
How can I set the start and endattribute within the node tag?
Came across that same problem. Networkx 2.1 still does not support that, but there is a workaround:
Write the .gexf file as usual
Download Gephi 0.9.2 and open the .gexf file
Go to Data Laboratory and press 'Merge Columns'. Now select the start and end column and 'Merge Strategy': 'Create time interval'. Now your Interval column is filled with <[start, end]>
Go to File > Export > Graph file... and select File Format:GEXF Files. Your nodes now contain the start and end attribute.

How is the fetchXML Date Operator resolved by the system

CRM 2013-OnPremise
Hello,
I have written a basic View for projects with a start date in the next seven days that is defined by this fetchXML:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
<entity name="xxxx_project" >
<attribute name="xxxx_startdate" />
<attribute name="xxxx_accountid" />
<attribute name="xxxx_produom" />
<order attribute="xxxx_name" descending="false" />
<filter type="and" >
<filter type="and" >
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="xxxx_projectstatus" operator="eq" value="331420009" />
<condition attribute="xxxx_materialsshipdate" operator="null" />
<condition attribute="xxxx_startdate" operator="next-x-days" value="7" />
</filter>
</filter>
<attribute name="xxxx_projectid" />
</entity>
</fetch>
Now I was expecting the fetchXML to have the system date injected into it or at least a place holder such as:
<condition value='2012-03-08T15:10:00Z' />
Perhaps this value is added at runtime and is not part of the fetchTemplate? So Msoft does some runtime changes to something like this?
<condition attribute="xxxx_startdate" operator="next-7-days" value="2014-04-23" />
This article says it is injected http://social.microsoft.com/Forums/en-US/c5083689-65fb-474f-a7bc-2eff393016fe/datetime-on-or-after-of-fetchxml-questions?forum=crmdevelopment
But does not give me any idea of what that should look like.
The reason I ask is that I want to use this basic fetchXML as a template but inject a date of my choosing.
Any idea?
If you want to build dynamically the fetchXML simulating a next 7 days condition based on your date, you can always rewrite it using On or Before and On or After conditions.
For example
<condition attribute="xxxx_startdate" operator="on-or-after" value="2014-04-23" />
<condition attribute="xxxx_startdate" operator="on-or-before" value=2014-04-30" />

FetchXML View to Include Attributes from Nested Link-Entity

I would like to have a view that show attributes from 3 entities:
Statistics has a lookup to Account and Account has a lookup to Address.
The view is on Statistics and I want attributes from all 3 entities; is this even possible?
The problem is with the GridXML.
I want to include the attribute wl_city in the GridXML.
This is the FetchXML with link-entities:
<fetchxml>
<fetch version="1.0" output-format="xml-platform" mapping="logical">
<entity name="sb_statistics">
<order attribute="sb_amount" descending="false" />
<!-- It is easy to get these into the GridXML -->
<attribute name="sb_debtor" />
<attribute name="sb_date" />
<attribute name="sb_amount" />
<link-entity name="account" from="accountid" to="sb_debtor"
alias="relatedAccount" link-type="outer">
<!-- It is possible to get this into the GridXML
by using the link-entity alias: relatedAccount.wl_towncity -->
<attribute name="wl_towncity" />
<link-entity name="wl_postalcode" from="wl_postalcodeid"
to="wl_postaltowncity" alias="relatedAddress" link-type="outer">
<!-- I have trouble getting this attribute into the GridXML -->
<attribute name="wl_city" />
</link-entity>
</link-entity>
<attribute name="sb_statisticsid" />
</entity>
</fetch>
</fetchxml>
When I change the GridXML as below this error is displayed when the view is opened:
"To use this saved query, you must remove criteria and columns that refer to deleted or non-searchable items"
<layoutxml>
<grid name="resultset" object="10008" jump="sb_name" select="1" preview="1"
icon="1">
<row name="result" id="sb_statisticsid" multiobjectidfield="1">
<cell name="sb_amount" width="100" />
<cell name="sb_date" width="100" />
<cell name="sb_debtor" width="100" />
<cell name="relatedAccount.relatedAddress.wl_city" width="100" />
</row>
</grid>
</layoutxml>
The below GridXML shows this error when the view is opened:
"Unexpected Error An error has occured".
<layoutxml>
<grid name="resultset" object="10008" jump="sb_name" select="1" preview="1"
icon="1">
<row name="result" id="sb_statisticsid" multiobjectidfield="1">
<cell name="sb_amount" width="100" />
<cell name="sb_date" width="100" />
<cell name="sb_debtor" width="100" />
<cell name="relatedAddress.wl_city" width="100" />
</row>
</grid>
</layoutxml>
The GridXML below results in this error being shown when the view is opened:
"To use this saved view, you must remove criteria and columns that refer to deleted or non-searchable columns".
<layoutxml>
<grid name="resultset" object="10008" jump="sb_name" select="1" preview="1"
icon="1">
<row name="result" id="sb_statisticsid" multiobjectidfield="1">
<cell name="sb_amount" width="100" />
<cell name="sb_date" width="100" />
<cell name="sb_debtor" width="100" />
<cell name="wl_city" width="100" />
</row>
</grid>
</layoutxml>
This saved query works, but it only includes attributes from the primary entity and the first link-entity.
<savedquery>
<IsCustomizable>1</IsCustomizable>
<CanBeDeleted>0</CanBeDeleted>
<isquickfindquery>0</isquickfindquery>
<isprivate>0</isprivate>
<isdefault>0</isdefault>
<returnedtypecode>10008</returnedtypecode>
<savedqueryid>{df101ac4-2e4d-e311-9377-005056bd0001}</savedqueryid>
<layoutxml>
<grid name="resultset" object="10008" jump="sb_name" select="1" preview="1"
icon="1">
<row name="result" id="sb_statisticsid" multiobjectidfield="1">
<cell name="sb_amount" width="100" />
<cell name="sb_date" width="100" />
<cell name="sb_debtor" width="100" />
<cell name="relatedAccount.wl_city" width="100" />
</row>
</grid>
</layoutxml>
<querytype>0</querytype>
<fetchxml>
<fetch version="1.0" output-format="xml-platform" mapping="logical">
<entity name="sb_statistics">
<order attribute="sb_amount" descending="false" />
<attribute name="sb_debtor" />
<attribute name="sb_date" />
<attribute name="sb_amount" />
<link-entity name="account" from="accountid" to="sb_debtor"
alias="relatedAccount" link-type="outer">
<attribute name="wl_towncity" />
<link-entity name="wl_postalcode" from="wl_postalcodeid"
to="wl_postaltowncity" alias="relatedAddress" link-type="outer">
<attribute name="wl_city" />
</link-entity>
</link-entity>
<attribute name="sb_statisticsid" />
</entity>
</fetch>
</fetchxml>
<LocalizedNames>
<LocalizedName description="Statistics and Address" languagecode="1033" />
</LocalizedNames>
</savedquery>
Is GridXML limited to showing only attributes from the primary entity and the first link-entity?
This is not possible, according to the best of my knowledge, but please someone prove me wrong.
A limitation of GridXML appears to be that attributes can only be included that are from the first link-entity, not any nested link-entities.
It should work when using link-type="inner" for nested link.
<entity name="sb_statistics">
...
<link-entity name="account" from="accountid" to="sb_debtor"
alias="relatedAccount" link-type="outer">
<attribute name="wl_towncity" />
<link-entity name="wl_postalcode" from="wl_postalcodeid"
to="wl_postaltowncity" alias="relatedAddress" link-type="inner"> //link-type="inner"
<attribute name="wl_city" />
</link-entity>
</link-entity>
<attribute name="sb_statisticsid" />
</entity>
I have found no evidence that it can be done. With or without link-type='inner' the designer (in 2013) says, "The relatedAddress.wl_city column is no longer a valid column because it has been deleted as a column option. You need to remove this column and, if you want, add a different one."
It does NOT need multiple dereferrences, nor does that work. If you dump the keyValuePairs of the AttributeCollection returned by the fetch, you will see the key is relatedAddress.w1_city -- not its parent nor the combination.
Like the UI, it just appears the layout is limited to only root and children, no grandchildren nor further descendants.
I think it's a little late to answer this question, but maybe someone come to this post and find it helpful.
first thing you should know is that, fetchxml will return only column that are not null, so if you are querying a column that there is no data in that, then fetchxml automatically remove it from result set.
second thing is, if you have different table with different relationship, then alias name will be added to the column name, so in your case relatedAccount.wl_towncity and relatedAddress.wl_city is correct and not relatedAccount.relatedAddress.wl_city. in your example, you put alias name after each other that is not correct.
third thing that you should know is that when a nested result will return, the type is object, but original type AliasedValue , so first you have to cast the object to AliasedValue. then it become ready to cast it to OptionSetValue. after that you have to look for .Value that has the result of what you want
I made it work like this: I still have an issue with unresolved columnheaders.
<fetch distinct='true'>
<entity name='rdiac_riskobject'>
<attribute name='rdiac_riskobjectid' />
<attribute name='rdiac_name' />
<attribute name='rdiac_riskobjectproduct' />
<link-entity name='rdiac_riskobject_rdiac_propertydetail' from='rdiac_riskobjectid' to='rdiac_riskobjectid' intersect='true'>
<link-entity name='rdiac_propertydetail' alias='pd1' from='rdiac_propertydetailid' to='rdiac_propertydetailid'>
<attribute name='rdiac_valuestring' />
<link-entity name='rdiac_propertysvconfig' from='rdiac_property' to='rdiac_propertyid'>
<filter>
<condition attribute='rdiac_svfield' operator='eq' value='100000000'/>
</filter>
</link-entity>
</link-entity>
</link-entity>
<link-entity name='rdiac_riskobject_rdiac_propertydetail' from='rdiac_riskobjectid' to='rdiac_riskobjectid' intersect='true'>
<link-entity name='rdiac_propertydetail' alias='pd2' from='rdiac_propertydetailid' to='rdiac_propertydetailid'>
<attribute name='rdiac_valuestring' />
<link-entity name='rdiac_propertysvconfig' from='rdiac_property' to='rdiac_propertyid'>
<filter>
<condition attribute='rdiac_svfield' operator='eq' value='100000001'/>
</filter>
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>
<grid name='resultset' object='10139' jump='rdiac_riskobjectproduct' select='1' preview='0' icon='1' >
<row name='result' id='rdiac_riskobjectid' >
<cell name='rdiac_riskobjectproduct' width='100' />
<cell name='pd1.rdiac_valuestring' width='200' />
<cell name='pd2.rdiac_valuestring' width='200' />
</row>
</grid>

FetchXML Filters With Different Entities

I wish to filter my entities in CRM2011 using a fetchXML filter. However, I'm having issues with AND and OR groupings over different entities.
I am searching for clients based on their consent, where each client will have either 1 or 0 valid consents. I want to return the client if there is no valid consent. I also want clients returned if they have a consent, but not if the have a 'restricted' consent without the agency specified (eg. client.consent.type == 'restricted' AND client.consent.users CONTAINS user)
So far I have this:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="contact">
<attribute name="fullname" />
<attribute name="thr_verifiedproofofidentity" />
<attribute name="thr_interpreterrequired" />
<attribute name="emailaddress1" />
<attribute name="thr_consent" />
<attribute name="birthdate" />
<attribute name="thr_individualreferencenumber" />
<attribute name="contactid" />
<order attribute="fullname" descending="false" />
<filter type="and">
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="thr_consent" operator="not-null" />
</filter>
<link-entity name="thr_consent" from="thr_clientid" to="contactid" alias="aa">
<filter type="and">
<filter type="or">
<condition attribute="thr_consenttype" operator="eq" value="130120003" />
<condition attribute="thr_consenttype" operator="ne" value="130120003" /> *
</filter>
</filter>
<link-entity name="thr_thr_consent_thr_agency" from="thr_consentid" to="thr_consentid" visible="false" intersect="true">
<link-entity name="thr_agency" from="thr_agencyid" to="thr_agencyid" alias="ab">
<filter type="and">
<condition attribute="thr_agencyid" operator="eq" uiname="Test" uitype="thr_agency" value="(agency id goes here)" /> *
</filter>
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>
The only thing missing from this code is that I need an AND grouping for the two condition attributes market with the '*'.
Can this be done?
As Guido Preite points out, it would be easiery to use the Advanced find to create the Fetch Xml, rather than hand editing it.
But...
Since you're not doing any grouping, I would suggest not even using Fetch Xml, but instead go with one of the other supported SDK options (QueryExpressions, Linq to CRM, oData, etc).
I'm not sure I completely understand your request (if you could write your query as a SQL statement, it would be helpful), but I think you'll need to have 2 thr_consent link entity of link-type="outer". The first has your equal to 130120003 condition, the second has your links to the agency id condition.

Resources