I have two product XML look like:
1:- product-1.xml
.
.
.
.
<images merge-mode="add">
<image-group view-type="large">
<image path="product-123.jpg" />
</image-group>
</images>
.
.
2:- product-1-1.xml
.
.
.
.
<images merge-mode="add">
<image-group view-type="large">
<image path="product-124.jpg" />
<image path="product-125.jpg" />
</image-group>
</images>
.
.
I am importing both the files and I want to append the images for the same product (PRODUCT123) as
<images merge-mode="add">
<image-group view-type="large">
<image path="product-123.jpg" />
<image path="product-124.jpg" />
<image path="product-125.jpg" />
</image-group>
</images>
but it's not appending the images.
I used merge-mode="merge" also for the same but not getting the result as I expected.
Could anyone help me out that where I am doing wrong?
Sadly, what you want to achieve is currently not supported by the Salesforce B2C Commerce platform.
You cannot split the images of an image group into several files and expect that they will be merged.
Indeed, the file import mode should be MERGE, but what you have tried as element merge-mode="add" is not supported, and you should have received a warning when you have imported the file.
If you look at catalog.xsd schema from the documentation you would see the following under complexType.Product.Images type definition:
<xsd:attribute name="merge-mode" type="simpleType.MergeMode" default="merge" use="optional">
<xsd:annotation>
<xsd:documentation>
Used to control if specified image groups will be merged to or replace the existing image specification.
The values "merge" and "replace" are the only ones supported for the "merge-mode" attribute.
Attribute should only be used in import MERGE and UPDATE modes. In import REPLACE mode, using the "merge-mode" attribute is not
sensible, because existing image groups will always be removed before importing the image groups
specified in the import file.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
P.S. I would suggest that you look for an alternative solution for merging the data about images before sending it to Salesforce B2C Commerce instance.
Are you using ImportCatalog pipelet? Please check job configuration, import mode should be MERGE.
In my application there is a common Icon.xaml file which contains many PathGeometry Figures having unique key names like as shown below.
<PathGeometry x:Key="CloseGeometry" Figures="m 357.0883 499.0572 12.62375 12.6275 5.31375 -5.31625 -12.62625 -12.62625 12.62625 -12.61875 -5.31375 -5.3125 -12.62375 12.62 -12.6325 -12.62 -5.30375 5.3125 12.6175 12.61875 -12.6175 12.62625 5.30375 5.31625 12.6325 -12.6275 z"/>
<PathGeometry x:Key="NormalGeometry" Figures="M4.3685131,23.127279L4.3685131,47.283243 47.117023,47.283243 47.117023,23.127279z M25.087107,13.948568C23.539013,13.948568 22.286318,15.201555 22.286318,16.74834 22.286318,18.292325 23.539013,19.547214 25.087107,19.547214 26.6327,19.547214 27.886597,18.292325 27.886597,16.74834 27.886597,15.201555 26.6327,13.948568 25.087107,13.948568z M16.126242,13.948568C14.580646,13.948568 13.326751,15.201555 13.326751,16.74834 13.326751,18.292325 14.580646,19.547214 16.126242,19.547214 17.673136,19.547214 18.928329,18.292325 18.928329,16.74834 18.928329,15.201555 17.673136,13.948568 16.126242,13.948568z M7.1679735,13.948568C5.621069,13.948568 4.3685136,15.201555 4.3685131,16.74834 4.3685136,18.292325 5.621069,19.547214 7.1679735,19.547214 8.713438,19.547214 9.9674625,18.292325 9.9674625,16.74834 9.9674625,15.201555 8.713438,13.948568 7.1679735,13.948568z M0,10.684L53.755001,10.684 53.755001,51.668001 0,51.668001z M8.5679998,0L58.668022,0 64,0 64,5.6864691 64,45.317999 58.668022,45.317999 58.668022,5.6864691 8.5679998,5.6864691z"/>
<PathGeometry x:Key="MaximiseGeometry" Figures="M5.2010002,14.812L5.2010002,43.573997 56.098,43.573997 56.098,14.812z M29.868601,3.8869994C28.026201,3.8869996 26.534,5.3791947 26.534,7.2190399 26.534,9.0588851 28.026201,10.553 29.868601,10.553 31.7085,10.553 33.202,9.0588851 33.202,7.2190399 33.202,5.3791947 31.7085,3.8869996 29.868601,3.8869994z M19.200649,3.8869994C17.359457,3.8869996 15.867001,5.3791947 15.867001,7.2190399 15.867001,9.0588851 17.359457,10.553 19.200649,10.553 21.042044,10.553 22.536999,9.0588851 22.536999,7.2190399 22.536999,5.3791947 21.042044,3.8869996 19.200649,3.8869994z M8.5339746,3.8869994C6.6931,3.8869996 5.2010002,5.3791947 5.2010002,7.2190399 5.2010002,9.0588851 6.6931,10.553 8.5339746,10.553 10.37495,10.553 11.867,9.0588851 11.867,7.2190399 11.867,5.3791947 10.37495,3.8869996 8.5339746,3.8869994z M0,0L63.999001,0 63.999001,48.792999 0,48.792999z"/>
<PathGeometry x:Key="MinimiseGeometry" Figures="M 0 1, 1 1 "/>
.....
But my problem is that there are around 300 to 400 different PathGeometries and it becomes difficult to check whether particular type of Image exists or not.
Example:
If new WPF form is gettign developed by programmer in which s\he needs to use delete Icon then s\he will first check in Icon.xaml file whether it already exists or not, if not then it will be added.But this checking needs to be done manually which is a pain.
So is there any simplest way to preview or check whether particular iamge exists or not.
Currently, I konw two tools can help you preview PathGeometry data of xaml.
XamlPadX
Download: XamlPadX v4.0.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Grid>
<Path Stroke="Black" StrokeThickness="2" Data="M4.3685131,23.127279L4.3685131,47.283243 47.117023,47.283243 47.117023,23.127279z M25.087107,13.948568C23.539013,13.948568 22.286318,15.201555 22.286318,16.74834 22.286318,18.292325 23.539013,19.547214 25.087107,19.547214 26.6327,19.547214 27.886597,18.292325 27.886597,16.74834 27.886597,15.201555 26.6327,13.948568 25.087107,13.948568z M16.126242,13.948568C14.580646,13.948568 13.326751,15.201555 13.326751,16.74834 13.326751,18.292325 14.580646,19.547214 16.126242,19.547214 17.673136,19.547214 18.928329,18.292325 18.928329,16.74834 18.928329,15.201555 17.673136,13.948568 16.126242,13.948568z M7.1679735,13.948568C5.621069,13.948568 4.3685136,15.201555 4.3685131,16.74834 4.3685136,18.292325 5.621069,19.547214 7.1679735,19.547214 8.713438,19.547214 9.9674625,18.292325 9.9674625,16.74834 9.9674625,15.201555 8.713438,13.948568 7.1679735,13.948568z M0,10.684L53.755001,10.684 53.755001,51.668001 0,51.668001z M8.5679998,0L58.668022,0 64,0 64,5.6864691 64,45.317999 58.668022,45.317999 58.668022,5.6864691 8.5679998,5.6864691z" />
</Grid>
</Page>
Then put the PathGeometry data (string of the node "Figures") to the value of inside "Data":
Next, you need to click "Auto Parse" button in left top postion, you can view the rendering result (red border region in screenshot). See below, I just use the data second one from your data.
WPF Geometry Transformation Tool
Download: WPF Geometry Transformation Tool.
Put the string of the node "Figures" into the textarea of Input Geometry, then you can see the result (red border region in screenshot).
I have a user control library that will use as a custom tooltip for another window, the user control holds ImageSource of a imagebrush that reference to a directory . Inside the window, I have another class that will generate an image file to the directory same as the imagebrush.
However i get an error below after run.
The call stack contained only external code.
'The invocation of the constructor on type 'WpfApplication2.MainWindow' that matches the specified binding constraints threw an exception.' Line number '4' and line position '9'
Here is my snippet.
UserControl1.xaml
<UserControl.Resources>
<Style TargetType="Rectangle">
<Setter Property="Fill">
<Setter.Value>
<ImageBrush ImageSource="C:\Users\user\Desktop\wpf\WpfApplication2\WpfApplication2\Images/QR.png" Stretch="Fill" />
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
DisplayWindow.xaml
xmlns:myToolTip="clr-namespace:WpfControlLibrary2;assembly=WpfControlLibrary2"
<myToolTip:UserControl1 Visibility="Collapsed" x:Name="customToolTip" Width="468" Height="700" />
QRCodeEncoder.cs
public QrCodeEncodercs(string encodeString)
{
QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
QrCode qrCode = new QrCode();
//const string encodeString = "123";
qrEncoder.TryEncode(encodeString, out qrCode);
Renderer renderer = new Renderer(11, System.Drawing.Brushes.Black, System.Drawing.Brushes.White);
renderer.CreateImageFile(qrCode.Matrix, #"C:\Users\user\Desktop\wpf\WpfApplication2\WpfApplication2\Images\QR.png\Images\QR.png",
ImageFormat.Png);
}
DisplayWindow.xaml.cs
When i run the constructor of the class above. The error mentioned above happened.
qce = new QrCodeEncodercs(videoName);
What happened actually? Any guidance? Thanks in advance.
Edit____InnerException
InnerException: System.Runtime.InteropServices.ExternalException
HResult=-2147467259
Message=A generic error occurred in GDI+.
Source=System.Drawing
ErrorCode=-2147467259
StackTrace:
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at Gma.QrCodeNet.Encoding.Windows.Controls.Renderer.CreateImageFile(BitMatrix matrix, String fileName, ImageFormat imageFormat)
at WpfApplication2.DisplayWindow.QrCodeEncodercs(String encodeString) in c:\Users\user\Desktop\wpf\KinectREAL\WpfApplication2\WpfApplication2\DisplayWindow..xaml.cs:line 127
at WpfApplication2.DisplayWindow.PopulateVideoListAndFirstVideo() in c:\Users\user\Desktop\wpf\KinectREAL\WpfApplication2\WpfApplication2\DisplayWindow..xaml.cs:line 157
at WpfApplication2.DisplayWindow..ctor() in c:\Users\user\Desktop\wpf\KinectREAL\WpfApplication2\WpfApplication2\DisplayWindow..xaml.cs:line 79
at WpfApplication2.MainWindow..ctor() in c:\Users\user\Desktop\wpf\KinectREAL\WpfApplication2\WpfApplication2\MainWindow.xaml.cs:line 45
InnerException:
These Generic error in GDI+ exceptions can be cryptic at times. One cause I've experienced in the past is when an image file has an incorrect extension (eg: a JPG ssaved with a GIF extension). My second guess would be that the filename in the path of the file you're saving to is invalid. Does the directory exist?
If the file is in use, you could copy it to a temporary directory with File.Copy and get a temporary filename with Path.GetTempFilename().
I manage to solve after some trying and it works so far. Thanks again.
System.Windows.Media.Imaging.BitmapImage bi = new System.Windows.Media.Imaging.BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri(#"C:\Users\user\Desktop\wpf\WpfApplication2\WpfApplication2\Images\QR.png", UriKind.RelativeOrAbsolute);
bi.CacheOption = System.Windows.Media.Imaging.BitmapCacheOption.OnLoad;
bi.EndInit();
image.Source = bi;