SilverCart Forum

We moderate this Forum and we're here to help. Have you already run a forum search to check if your problem has already been solved?

You can help us helping you by providing detailed error messages, screenshots and logfile entries.

SebastianRamon

Page: 1
Topic Latest products widget 2737 Views

Latest products widget

4 October 2011 at 1:06pm

Hello all,

I'm wondering if someone can help me with this. I need a list of latest products that I can drop in at will on various parts of the site.

Looking at it, it seems widgets would be the way to do it but it's not clear to me how you actually go about defining a new one.

Two questions:
i) What are the exact steps for adding a custom widget?
ii) Theoretically, to list the latest products, would you have to recursively loop through productgroups by id and then select the latest? It seems like there should be one way of simply returning latest products regardless of group but I can't seem to find it.

Anyway, I realise the questions above may be a little too newbie or basic but, well, I am a newbie and basic :)

Thanks,

Andrew

Re: Latest products widget

5 October 2011 at 9:36am Last edited: 5 October 2011 9:37am

Hi Andrew,

widgets would indeed be a good way to accomplish this task.

Regarding your questions:

i)
Currently there's no documentation on that topic, but we're working on it now. I'll drop you a line in this thread when it's done (should be later this day :)

ii)
To list the latest products you don't have to recursively loop through productgroups. Instead you could use the following call:

$latestProducts = DataObject::get(
'SilvercartProduct', null, 'Created DESC', null, 5
);

This should return a DataObjectSet with 5 SilvercartProducts, ordered by the creation date. If you want to use the last modification time just replace 'Created DESC' with 'LastEdited DESC'.

Best regards,
Sascha

Re: Latest products widget

6 October 2011 at 3:39pm

Hello Andrew,

the documentation for the SilverCart widget system is available now.

In the userbase documentation you can find instructions on how to configure widgets and widget sets in the storeadmin.

The techbase describes what you asked for and sports a tutorial on how to write custom widgets.

You can find the userbase documentation here:
http://pixeltricks.de:8095/display/SILHBEN/Widgets

The techbase documentation can be found under this link:
http://pixeltricks.de:8095/display/SILHBEN/The+SilverCart+Widget+System

If more questions occur or you got proposals for improvements of the documentation don't hesitate to write us here :)

Best regards,
Sascha

PS: currently we're updating our documentation system, so don't be surprised that the links I gave don't point to the www.silvercart.org documentation pages but to our confluence wiki.

Re: Latest products widget

6 October 2011 at 3:55pm

Hi Sascha,

You're a star, that's massively useful and I hope to be giving it a bash very soon. Thanks again for the help.

Regards,

Andrew

Re: Latest products widget

10 October 2011 at 6:13pm

Hi Sascha,

Thanks again for the tutorial. I've followed it through twice now though, pretty sure I'm following all steps correctly but hitting a problem.

I get as far as the end, run dev/build. No errors reported but then the widget is not available via the admin. Is there a step I'm missing here to actually enable it or a way to troubleshoot perhaps?

Any advice appreciated.

Thanks,

Andrew

Re: Latest products widget

10 October 2011 at 6:59pm

Hi Andrew,

can you send me your code to skoehler [at] pixeltricks [dot] de? I'll have a look and try to find out what's wrong tomorrow.

Regards,
Sascha

Re: Latest products widget

11 October 2011 at 3:20pm

If anybody else is reading this thread: Andrew and us found the solution.

First the directory "silvercart_widgets_latest_products" was placed inside the directory "silvercart" instead outside. The documentation wasn't clear on that and has been updated accordingly.

Another hiccup occured with the lang file. The documentation says you should create a "en_US" lang file whereas the installation of Andrew was "en_GB" based. The naming and contents of the file should always be changed to the language you're using. The documentation has been updated on this topic, too.

Thanks Andrew for your valuable feedback and happy SilverCarting ;)