Jump to:

2082 Posts in 1002 Topics by 452 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » plans for extending images in ecommerce?

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1
Go to End
Author Topic: 961 Views
  • supermegaultra
    Avatar
    Community Member
    33 Posts

    plans for extending images in ecommerce? Link to this post

    Hey guys,

    Are there any plans at all on making a module for easily addable multiple images for ecommerce?

    Something like what trademe.co.nz have would be amazingly beneficial.

    I would but I don't have anywhere near enough skills to do something like this..

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: plans for extending images in ecommerce? Link to this post

    Not sure what the plans are for the ecommerce module and this. But if you look around you'll find some useful posts on DataObjectManager and the gallery.
    I got multiple images working on a site I haven't yet made live yet. I like to make a seperate DataObject to handle the images, so I can include captions and fancy stuff. But it might be easier for you to not worry about that to start with.
    It'll take some PHP coding on your part, but there is plenty of help around.
    If you look in ecommerce/code/products/Product.php on line 28

       public static $has_one = array(
          'Image' => 'Product_Image'
       );


    You'll want many so, change the "has_many" array to include many product images.

       public static $has_many = array(
          'Variations' => 'ProductVariation',
          'Images' => 'Product_Image'
       );


    Then you'll need to add a few lines to the getCMSFields function to add a form for you to add mulitple images. This is where I find the DataObjectManager module REALLY useful. If you download it and add it to your site you should be able to add a field like

          $MyImageManager= new DataObjectManager(
             $this,   
             'Images',
             'Product_Image'
          );
          $fields->addFieldToTab("Root.Content.Images", $MyImageManager);

    The next thing will be to print the added images to your template. I think this should work.

    <% control Images %>
    $Product_Image
    <% end_control %>

  • supermegaultra
    Avatar
    Community Member
    33 Posts

    Re: plans for extending images in ecommerce? Link to this post

    Thanks heaps for that Bambi!

    I've installed DataObjectManager and have updated my files like you instructed and it all seems good to go!

    One issue remains is that the last bit about adding the images to the template.. Can't get them to show?

    I have added: <% control Images %> $Product_Image <% end_control %>
    replacing the original call for the images were in my ecommerce/templates/layouts/product.ss:

          

    <% if Image.ContentImage %>
             <img class="productImage" src="$Image.LargeImage.URL" alt="<% sprintf(_t("IMAGE","%s image"),$Title) %>" />
          <% else %>
             <img src="ecommerce/images/productPlaceHolderNormal.gif" alt="<% sprintf(_t("NOIMAGE","Sorry, no product image for &quot;%s&quot;"),$Title) %>" />
          <% end_if %>

    Is this right? Lookin forward to your help. It's already been a huge help!

  • supermegaultra
    Avatar
    Community Member
    33 Posts

    Re: plans for extending images in ecommerce? Link to this post

    Hey again guys,

    I've made progress with this thanks to Bambi's help. I have the dataobjectmanager showing on each product page in the backend.. But still have not been able to show the additional images I want on the frontend product page.

    Have also noticed there is an issue where there is no control over what images show for that specific product in the form where I add mulitple images. It displays all of the files in the assets/uploads folder for ever product.

    Could someone please supply the code for their products.php and products.ss files?

    Much appreciated.

    961 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.