Developer forum

Forum » Ecommerce - Standard features » Publication period for the products doesn't work.

Publication period for the products doesn't work.

Khine Lwin Myint
Reply

Hi , 

I set up the publication period for the product like the attached images in version 9.5.3. After that, I rebuilt the product index. But, the product is still showing in the frontend. 

Can you please let me know if I am missing to set up some settings?

Best Regards,

Khine

Image_1.png Image_2.png

Replies

 
Nicolai Pedersen
Reply

Hi Khine

You probably have to add the criteria to the query in the repository

BR Nicolai

 
Khine Lwin Myint
Reply

Hi Nicolai, 

Can you please let me know where I can find the sample query ? Or could you please show me the sample query to be added in the reporitory?

I want to show the product within that created publication period and the product won't be displayed in the frontend after that period. 

Best Regards,

Khine

 
Nicolai Pedersen
Reply

I belive this should do it. See attachment.

BR Nicolai

Capture.PNG
 
Khine Lwin Myint
Reply

There are two scenarios in the customer requirements for publication periods. One period is from 14th Jan to 20th Jan and another is from 14th Jan to 21th Jan. 

How can I do that?

Best Regards,

Khine

 
Nicolai Pedersen
Reply

Not sure I understand.

On the product you set the publication period - one product can only have one publication period. You cannot combine the dates and the publication periods. The latter is a combined way to make the same publication for multiple products, i.e. "Easter", "Christmas" or something like that.

BR Nicolai

 
Tin Ma Ma
Reply

Hi Nicolai,

May I know what is the correct date time format for Campaign: Start time and End Time?


Regard,

Tin Ma Ma

Image_2.png
 
Nicolai Pedersen
Reply

Try 2019-1-14

 
Tin Ma Ma
Reply

Hi Nicolai,

Hit the error in product list

Regards,

Tin Ma Ma

 

Image_4.png
 
Nicolai Pedersen
Reply

The error says it all... What the string should be, depends on the server culture.

But I do not understand why you will want to make this query with hardcoded value?

NP

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
Try with either 2019-01-14 or 2019-01-14T00:00:00
 
Tin Ma Ma
Reply

Hi

There are 3 scenario for publication.

(1) Product A publish on Jan 14 to Jan 18.
(2) Product B publish on Jan 14 to Jan 20.
(3) Product C publish during Chinese New Year period

Kindly help me to advise how can I setup for these 3 scenario .
Thanks and Regards,

Tin Ma Ma

 
Tin Ma Ma
Reply

Hi Morten,

I tried both format 2019-01-14 or 2019-01-14T00:00:00.


Still hit error

System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at Dynamicweb.Core.Helpers.TypeParser.ParseDateTime(String value) at Dynamicweb.Core.Helpers.TypeParser.Parse(String type, String value) at Dynamicweb.Indexing.Querying.Expressions.ConstantExpression..ctor(String valueString, String typeString) at Dynamicweb.Indexing.Querying.Expressions.ExpressionHelper.DeserializeFromXml(XElement element) at Dynamicweb.Indexing.Querying.Expressions.ExpressionHelper.DeserializeFromXml(XElement element) at Dynamicweb.Indexing.Querying.Expressions.ExpressionHelper.DeserializeFromXml(XElement element) at Dynamicweb.Indexing.Querying.Expressions.ExpressionHelper.DeserializeFromXml(XElement element) at Dynamicweb.Indexing.Querying.Expressions.ExpressionHelper.DeserializeFromXml(XElement element) at Dynamicweb.Indexing.Querying.QueryHelper.ConvertToQuery(XElement obj) at Dynamicweb.Indexing.Querying.QueryService.LoadQuery(String fileName) at Dynamicweb.Indexing.Querying.QueryService.LoadQuery(String repository, String item) at Dynamicweb.Indexing.Querying.Faceting.FacetGroupHelper.ConvertToFacets(XElement obj) at Dynamicweb.Indexing.Querying.QueryService.LoadFacets(String fileName) at Dynamicweb.Ecommerce.Frontend.Frontend.GetProductsFromIndexQuery()

Regards,

Tin Ma Ma

 
Nicolai Pedersen
Reply

Hi Tin Ma Ma

If you need your scenario, just set up that as the pblication period on the products and use the query as I showed you. No dates in the query!

BR Nicolai

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Anyway we could do this? I have a customer who wants to be able to select specific dates as the "value" in the expression.

 

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen
Reply

Nope.

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Ok,

 

If needed, I'll create a macro or some way for the the user to select a date. I am assuming that if there are Macros to get the current date, I can build one that returns a date value (not a string).

 

Thanks,

Nuno

 
Nicolai Pedersen
Reply

You can use a codeprovider, see dump.

 

Here is our code:

Imports Dynamicweb.Extensibility.AddIns
Imports Dynamicweb.Extensibility.Editors
Imports Dynamicweb.SystemTools
Imports Dynamicweb.Extensibility.Providers

Namespace Extensibility.CodeProviders
    <AddInName("Dynamicweb.ICodeProvider"), AddInLabel("DateTime Provider"), AddInActive(True), AddInGroup("System.DateTime")>
    Public Class DateTimeCodeProvider
        Inherits CodeProviderBase
        Implements ICodeProvider, IDropDownOptions

        <AddInParameter("Number"), AddInParameterEditor(GetType(IntegerNumberParameterEditor), "inputClass=inputControl"), AddInParameterGroup("Source")>
        Public Property Number As Integer

        <AddInParameter("Interval"), AddInParameterEditor(GetType(DropDownParameterEditor), "inputClass=inputControl"), AddInParameterGroup("Source")>
        Public Property Interval As String

        Public Overrides Function BuildCodeString() As String
            'Basically not used anymore because Execute is now being overriden
            Return String.Format("@Code(DateTime.Now.Add{0}({1}))", Interval, Number)
        End Function

        Public Overrides Function BuildDisplayValue() As String
            Return String.Format("Today {0} {1} {2}", If(Number >= 0, "+", "-"), Math.Abs(Number), Interval)
        End Function

        Public Overrides Function Execute() As Object
            Select Case Interval
                Case "Minutes"
                    Return DateTime.Now.AddMinutes(Number)
                Case "Hours"
                    Return DateTime.Now.AddHours(Number)
                Case "Days"
                    Return DateTime.Now.AddDays(Number)
                Case "Months"
                    Return DateTime.Now.AddMonths(Number)
                Case "Years"
                    Return DateTime.Now.AddYears(Number)
            End Select
            Return DateTime.Now
        End Function

        Public Function GetOptions(dropdownName As String) As Hashtable Implements IDropDownOptions.GetOptions
            ' Get Hashtable
            Dim options As New Hashtable

            options.Add("Minutes", Translate.Translate("Minutes"))
            options.Add("Hours", Translate.Translate("Hours"))
            options.Add("Days", Translate.Translate("Days"))
            options.Add("Months", Translate.Translate("Months"))
            options.Add("Years", Translate.Translate("Years"))

            ' Return the hashtable
            Return options
        End Function
    End Class
End Namespace

Capture.PNG
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Thanks. I will use that. I believe the customer is looking for something like "list of products available for promotion during Easter". Not necessarily to advertise product lists ahead of time, but for some internal queries, so explicitly setting dates are important to them (not internals like the current code provider allows).

 

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen
Reply

Alright - then maybe make a period called easter and filter on that instead...

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Yeah, we'll try to use Publicatio Periods for that scenario, but we'll need a custom code provider anyway. I just checked against the requirements and we have some custom date fields (for example, Release Date), so they want to get a query of products released in 2018. That means selecting a specific date (expression value) against a custom field. It does not seem to be an issue. We can custom develop this.

 

Best Regards,

Nuno Aguiar

 
Yoon Peti Nwe Dynamicweb Employee
Yoon Peti Nwe
Reply

Dear Sir Nicolai,

One of our customer want to setup the publication period as March for some of the product and until March those product should not come out in the product list and search.

Therefore, I try to setup like below screenshot.

Unfortunately even I run the product repository the product still appear in the product list page and when clicking on that particular product it redirect me to the 404 page.

And then I try to setup the below expression on the product query but none of the product come out in the product list.


Please kindly advice is there any other setting that I missed out or is there any way that we can make not to appear those product which had setup future publication period?

Looking forward to hearing from you.

Thanks,

Yoon

 

You must be logged in to post in the forum