Close

Profile: cyberspy

Avatar

User posts

Boyko wrote:
I think the best way to approach this without writing too much code is to have both images in the PictureModel. This model has a dictionary CustomProperties that you can use to store the second image and then in the Razor views you can get the second image from the CustomProperties where necessary.


Boyko,

I understand now why the signature is so important - I didn't realise you where overriding this method.

You idea does have merit, but I still have some questions:

First, the PictureModel does not have a CustomProperties property. The definition of this model is:

namespace Nop.Web.Models.Media
{
    public partial class PictureModel : BaseNopModel
    {
        public string ImageUrl { get; set; }
        public string FullSizeImageUrl { get; set; }
        public string Title { get; set; }
        public string AlternateText { get; set; }
    }
}

Would adding an additional property to this model cause additional problems with nopTemplates plugins?
The easiest and most flexible would probably to provide an AlternateImage property, which would itself be a nested PictureModel, so all the properties are available.


Second, although just providing the second image as the alternate may be sufficient now, I'd still like to be able to select at run time (in the view) which image to provide as the alternate image. This is what the extra property was for.

However, even as I write this message I think I've solved it.
If each picture model contains a reference to a child picture model, then I can chain multiple picture models together, so all the images are returned in display order. If the PictureModel has some code to return a particular image (or the last image if the number requested is greater than the number of images available) then any view can use any image for the selected product.

I'd like your thoughts on this and especially whether or not any plugins will have similar issues when I extend the PictureModel.

Regards

Adam

Boyko,

Thank you for responding so quickly.

What I am trying to achieve is this.

When a product has more than one image, I want to be able to choose which image appears on the site in the different places these images are displayed.

So, for example, the first image would appear in the carousel (I can't change the carousel, so the first, default image will appear there)  but in a product panel on the home page (I'm using your Alfresco theme btw) I want another image.

So, to achieve this, I think the simplest way is to use the display order which can be applied to product images. This gives administrators the ability to choose which image appears in each location (although the display number probably needs to be hard coded in the places where this feature is used).

This can be done by passing the display order number to the controller from the view that will display the images

So, for example, on the home page, we have the line:

        @Html.Action("HomepageProducts", "Catalog")

This is the default, and will display the first image.

I want to use this instead:

        @Html.Action("HomepageProducts", "Catalog", new { productPictureNumber = 2 })

The controller action then looks like this:

  protected IEnumerable<ProductOverviewModel> PrepareProductOverviewModels(IEnumerable<Product> products,
            bool preparePriceModel = true, bool preparePictureModel = true,
            int? productThumbPictureSize = null, bool prepareSpecificationAttributes = false,
            bool forceRedirectionAfterAddingToCart = false, int productPictureNumber = 0)
        { ... }

This number is passed to the PictureService.GetPicturesByProductId method which will use it to select the correct image (\WebProject\Libraries\Nop.Services\Media\PictureService.cs line 688)

This should be a simple change to make and would solve my problem.

This additional value would not affect the carousel - it would still get its images.

I don't want to have to create an entirely new action in the catalog controller, and then go through the app and call it whenever I want to use this feature - that's extra work, and would entail maintaining two copies of the action in the controller. One of the major features of modern code like MVC is code reuse, and having to duplicate a method to add an additional OPTIONAL parameter breaks this concept.

So, How do I work around this restriction?

Also, out of curiosity, how do you even do this, force a method to keep the same signature? All the other places that call this controller action are quite happy with it - they do not break at run time, so this 'feature' must have been explicitly encoded. How is this done?

I've got a bit of a deadline to work to here, so I'd really appreciate a quick solution to this.

Thanks & Regards

Adam

Support wrote:


Please note that all our products are guaranteed to work only for the official nopCommerce release and not custom builds.

I see that you have added a new parameter and that is why the Nop Ajax Filters throw an error as they rely on this method. Even if you make the parameter to be an optional, this will not work as this is a breaking change.



I have extended the same method (PrepareProductOverviewModels in CatalogController) and have the same problem.

Your response however is most disappointing. I understand that your plugins are only guaranteed to work on the official release, it seems you have made a decision to deliberately force the method to remain standard, rather than allow developers to extend it and then take responsibility for the consequences.

If I create another PrepareProductOverviewModels, with all the same optional parameters as the original, and with one more, then when the method is called with only a few methods, then it  causes an "The call is ambiguous between the following methods or properties:" error when building.

I've added the following method, to keep jCarousel plugin happy and added the extra parameter to the original method and used a default value in the new method ( the extra 0 after forceRedirectionAfterAddingToCart)


        [NonAction]
        protected IEnumerable<ProductOverviewModel> PrepareProductOverviewModels(IEnumerable<Product> products,
            bool preparePriceModel = true, bool preparePictureModel = true,
            int? productThumbPictureSize = null, bool prepareSpecificationAttributes = false,
            bool forceRedirectionAfterAddingToCart = false)
        {
            return PrepareProductOverviewModels(products, preparePictureModel, preparePictureModel, productThumbPictureSize,
               prepareSpecificationAttributes, forceRedirectionAfterAddingToCart, 0);
        }

So far, I've been very impressed with the quality of your plugins and themes, but this has really knocked my confidence in my ability to use your plugins and to continue to extend nopCommerce.

Surely there must be a better way of doing this?

Bugs
10 years ago

Hi,

I've just been looking for where I change these values, and it doesn't seem possible.

SevenSpikes.Themes.Alfresco.Common.CompanyInfo
SevenSpikes.Themes.Alfresco.Common.CustomerServices
SevenSpikes.Themes.Alfresco.Common.FAQ
SevenSpikes.Themes.Alfresco.Common.Help
SevenSpikes.Themes.Alfresco.Common.OurOffers
SevenSpikes.Themes.Alfresco.Common.Search
SevenSpikes.Themes.Alfresco.Common.MenuTitle
SevenSpikes.Themes.Alfresco.Common.Phone
SevenSpikes.Themes.Alfresco.Common.EmailName
SevenSpikes.Themes.Alfresco.Common.EmailDomain

They are not included on the theme's Widget Config page, which is where I'd expect them to be.

Regards

Adam

Bugs
10 years ago

Aleks wrote:

Thank you for pointing out that bug. We took your suggestion in consideration and we've developed a better way for the buttons to be positioned and displayed in all resolutions both with or without a title.


Thanks for this - it has indeed fixed the issue.
The controls are quite big though and as they are outside the carousel now, they take a lot of space.

This can be tweaked via the CSS file though so it's not a big problem.

Regards

Adam

Bugs
10 years ago


Support wrote:
By design in the Nop Alfresco theme in the Nop JCarousel items only the details button and the title should be links pointing to the product page. There was a bug in the theme, but we have fixed that and uploaded on our site. You can download the theme again and replace the ~/Plugins/SevenSpikes.Nop.Plugins.JCarousel/Views/JCarousel/JCarousel.cshtml file with the one from the downloaded theme.

Please let us know if the problem still exists!


Sorted! Excellent response - Thanks

I see the responsive issue I mentioned in my second post returned after I replaced the plugin (I'd fixed it in CSS) so this has not been fixed.
Is this because you've not had a chance to review my suggestions, or I've caused another issue with my suggested changes?

Regards

Adam

Bugs
10 years ago

Having just installed jCarousel, I tested it on different size screens as I'm using the responsive Alfresco theme.

It works fine in full size, max-width 980 and 768 but breaks a bit in the smallest size, max-width 480

What happens is the the two left and right arrows, instead of overlaying the right-hand image, move above the carousel.
I had put the carousel in the 'home_page_top' zone.

At this small size, the left/right arrows are half overlayed over the main Menu. This looks very odd.

The solution is simple though - copy the CSS rules from the next largest size into the max-width 480px section. Here are the changes I made:


@media screen and (max-width: 480px) {

    .nop-jcarousel .carousel-title {
        margin: 0 5px 60px;
    }

    .nop-jcarousel .jcarousel-prev-horizontal, .nop-jcarousel .jcarousel-next-horizontal {
        /*bottom: 244px;
        top: inherit;*/

        padding: 6px;
    }
    .nop-jcarousel .jcarousel-prev-horizontal {
        right: 61px; /* New rule */
        /*left: 43%;
        margin-left: -20px;*/

    }
    .nop-jcarousel .jcarousel-next-horizontal {
        /*right: 43%;
        margin-right: -20px;*/

    }
    .nop-jcarousel .item-info {
        display: none !important;
    }
}

Bugs
10 years ago

Hi,
I've just added jCarousel to my site (which is still under development so it's not publicly visible)
I used the 'Home Page Featured Products' as the data source type, and it's fully populated with products, and it scrolls correctly most of the time. So far so good.
When I mouse over a product, a grey panel slides up with the name of the product, the price and a 'Details' button
If I click the 'Details' button, I'm taken off to the correct product page

However, if I click anywhere else in the grey panel, it takes me off to a page called /undefined, with the resultant 404 message

How can I make the URL of the grey panel point to the same place as the 'Details' button.

I'm using nopCommerce 3.10 with the Alfresco theme and the plugins that came with that theme.

Thanks