MediaPicker field pb with Nwazet.Commerce

Topics: Customizing Orchard, General, Troubleshooting
Feb 4 at 11:02 AM
Edited Feb 4 at 11:31 AM
[Help Bertrand]
I have a custom content type using a mediapicker field.
After I installed Nwazet.commerce for evaluation, the Admin Content display of my custom type contents was disturbed, the image was displayed before my content.
I have not even created anything in the ecommerce module, just enabled it.
Setting a break point in the Render method of ShapeTemplateBindingStrategy, I realized that there was a BindingSource called named .....\Modules\Nwazet.Commerce\Views\MediaPickerProductImageSummaryAdmin.cshtml which was called to display the image field....
see Image
Any explanation welcome.

I am using a custom theme, here is my placement info
<Placement>
  <!-- Customize where the shapes are rendered -->
<Placement>
  <Match Path="~/">
    <Place Parts_Title="-"/>
    <Place Parts_Common_Metadata="-"/>
  </Match>
</Placement>
the placement info of my custom type, BSCarouselSlide, is here
<Placement>
    <Place Parts_BSCarouselSlide="Content:2"/>
    <Place Parts_BSCarouselSlide_Edit="Content:2"/>
  <Match DisplayType="SummaryAdmin">
    <Place Parts_BSCarouselSlide="Content:1;Alternate=Parts_BSCarouselSlide_SummaryAdmin"/>
    <Place Fields_MediaPicker="-"/>
    <Place Parts_Title="Content:1"/>
  </Match>
  <Match DisplayType="Summary">
    <Place Parts_BSCarouselSlide="Content:1;Alternate=Parts_BSCarouselSlide_Summary"/>
  </Match>
</Placement>
``` Last comment, my code is the last december v1.6.
Feb 4 at 2:59 PM
Edited Feb 4 at 3:01 PM
this method is NOK, for fields, it simply gets the last shape entered in the system without any regards to Contentype of the field which should have a priority in the search
Very fast but too fast. Looks like a bug.

        static bool TryGetDescriptorBinding(string shapeType, IEnumerable<string> shapeAlternates, ShapeTable shapeTable, out ShapeBinding shapeBinding) {
            // shape alternates are optional, fully qualified binding names
            // the earliest added alternates have the lowest priority
            // the descriptor returned is based on the binding that is matched, so it may be an entirely
            // different descriptor if the alternate has a different base name
            foreach (var shapeAlternate in shapeAlternates.Reverse()) {
                if (shapeTable.Bindings.TryGetValue(shapeAlternate, out shapeBinding)) {
                    return true;
                }
            }
Feb 4 at 11:01 PM
Edited Feb 4 at 11:04 PM
After some Googlelizing I created a public class ShapeProvider : IShapeTableProvider
trying to be faster than Ecommerce Product.

Her I spent lot of time trying to understand the fact that when you ask Orcherd to add an alternate named according next line

displaying.ShapeMetadata.Alternates.Add("fields_mediapicker_summaryadmin__image")

it is because you have a file named fields.mediapicker-Image.summaryadmin.cshtml
do note the inversion between field name and displaytype ????

Is it due to this, I think it's a bug ?
http://orchard.codeplex.com/discussions/430485

It is a little dammage having to create code because the shape detection is not optimized to try its first match on the templates in the contentype where is the field......
Feb 5 at 12:32 PM
Edited Feb 5 at 12:36 PM
I just discovered that there are 2 versions of nwazet commerce.... bad... I just realized I updated the mercurial url and merged the 2 !!!!
I think the error I encountered was in the original part of code, but it seems that I was working on the ems version from december.....
I open a new thread for this.
Coordinator
Feb 10 at 7:01 AM
I'm totally confused by this. Is there a problem here I need to look at?
Feb 10 at 8:04 AM
Bertrand,
I think that the MediaPickerProductImageSummaryAdmin.cshtml when installed by the ecommerce module is taking precedence on any contenttype using a medipickerfield and is used to render the mediapickerfield of any such contenttype. This for the display of Content in admin.
This was breaking my page with very large pictures where I was previously reducing the image size in this screen.
Coordinator
Feb 10 at 8:11 PM
OK, can you please create a bug on Bitbucket to track this and I'll look at it?