Post by Hekep » Wed Mar 25, 2020 4:09 pm

Hello,

We are using Opencart 3 and Journal 3. Is there any update on this how product is considered as new?
Last edited by OSWorX on Wed Mar 25, 2020 4:47 pm, edited 1 time in total.
Reason: moved to correct forum!

Newbie

Posts

Joined
Wed Mar 25, 2020 4:07 pm

Post by letxobnav » Wed Mar 25, 2020 6:26 pm

Default there is no idication as to when a product is considered "new".

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by paulfeakins » Thu Mar 26, 2020 6:12 pm

Is it not just the most recent x number of products?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by letxobnav » Thu Mar 26, 2020 6:27 pm

you can interpret it that way but that does not identify a new product just a list of all products sorted by their date-added.

You could set a limit of x weeks or months and then compare the product date-added to that or you can do it individual by storing the last visit-date in a cookie and compare the products date-added/updated to that.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Thu Mar 26, 2020 6:31 pm

paulfeakins wrote:
Thu Mar 26, 2020 6:12 pm
Is it not just the most recent x number of products?
Not exactly. The most recent products can also be on the date and time rather than quantity-based during a time interval period.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Thu Mar 26, 2020 6:38 pm

straightlight wrote:
Thu Mar 26, 2020 6:31 pm
paulfeakins wrote:
Thu Mar 26, 2020 6:12 pm
Is it not just the most recent x number of products?
Not exactly. The most recent products can also be on the date and time rather than quantity-based during a time interval period.
Yes, sorry that's what I meant, the most recently added products, but x of them are displayed. E.g. the most recent 10 to be added.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by straightlight » Thu Mar 26, 2020 8:02 pm

paulfeakins wrote:
Thu Mar 26, 2020 6:38 pm
straightlight wrote:
Thu Mar 26, 2020 6:31 pm
paulfeakins wrote:
Thu Mar 26, 2020 6:12 pm
Is it not just the most recent x number of products?
Not exactly. The most recent products can also be on the date and time rather than quantity-based during a time interval period.
Yes, sorry that's what I meant, the most recently added products, but x of them are displayed. E.g. the most recent 10 to be added.
Correct.

Tested in v3.0.3.2 release. In catalog/controller/extension/module/latest.php file,

find:

Code: Select all

if ($results) {
add below:

Code: Select all

$i = 1;
Then, find:

Code: Select all

$data['products'][] = array(
add above:

Code: Select all

if ($this->config->get('config_product_new')) {
					$new_date = new DateTime(date('Y-m-d H:i:s', strtotime($result['date_added'])));
				
					$current_date = new DateTime(date('Y-m-d H:i:s', time()));
				
					$new_interval = $new_date->diff($current_date)->days;								
				}
Then, find:

Code: Select all

'rating'      => $rating,
add below:

Code: Select all

'new'		  => ($this->config->get('config_product_new') && $this->config->get('config_product_new_limit') > 0 && $i <= $this->config->get('config_product_new_limit') && $new_interval > 0 && $new_interval <= $this->config->get('config_product_new_day') ? true : false),
Then, find:

Code: Select all

}

			return $this->load->view('extension/module/latest', $data);
add above:

Code: Select all

++$i;
In admin/controller/setting/setting.php file,

find:

Code: Select all

if (isset($this->error['encryption'])) {
			$data['error_encryption'] = $this->error['encryption'];
		} else {
			$data['error_encryption'] = '';
		}
add below:

Code: Select all

if (isset($this->error['product_new_limit'])) {
			$data['error_product_new_limit'] = $this->error['product_new_limit'];
		} else {
			$data['error_product_new_limit'] = '';
		}
		
		if (isset($this->error['product_new_day'])) {
			$data['error_product_new_day'] = $this->error['product_new_day'];
		} else {
			$data['error_product_new_day'] = '';
		}
Then, find:

Code: Select all

if (isset($this->request->post['config_error_filename'])) {
			$data['config_error_filename'] = $this->request->post['config_error_filename'];
		} else {
			$data['config_error_filename'] = $this->config->get('config_error_filename');
		}
add below:

Code: Select all

if (isset($this->request->post['config_product_new'])) {
			$data['config_product_new'] = $this->request->post['config_product_new'];
		} else {
			$data['config_product_new'] = $this->config->get('config_product_new');
		}
		
		if (isset($this->request->post['config_product_new_limit'])) {
			$data['config_product_new_limit'] = $this->request->post['config_product_new_limit'];
		} else {
			$data['config_product_new_limit'] = $this->config->get('config_product_new_limit');
		}
		
		if (isset($this->request->post['config_product_new_day'])) {
			$data['config_product_new_day'] = $this->request->post['config_product_new_day'];
		} else {
			$data['config_product_new_day'] = $this->config->get('config_product_new_day');
		}
Then, find:

Code: Select all

if ($this->error && !isset($this->error['warning'])) {
add above:

Code: Select all

if (isset($this->request->post['config_product_new']) && $this->request->post['config_product_new']) {
			if (!isset($this->request->post['config_product_new_limit']) || !filter_var($this->request->post['config_product_new_limit'], FILTER_VALIDATE_INT) || utf8_strlen($this->request->post['config_product_new_limit']) < 1) {
				$this->error['product_new_limit'] = $this->language->get('error_product_new_limit');
			}
			if (!isset($this->request->post['config_product_new_day']) || !filter_var($this->request->post['config_product_new_day'], FILTER_VALIDATE_INT) || utf8_strlen($this->request->post['config_product_new_day']) < 1) {
				$this->error['product_new_day'] = $this->language->get('error_product_new_day');
			}
		}
Then, in admin/language/en-gb/setting/setting.php file, find:

Code: Select all

$_['entry_error_filename']           = 'Error Log Filename';
add below:

Code: Select all

$_['entry_product_new']				 = 'Show New Products';
$_['entry_product_new_limit']		 = 'New Products Limit';
$_['entry_product_new_day']			 = 'New Products in Days';
Then, find:

Code: Select all

$_['help_compression']               = 'GZIP for more efficient transfer to requesting clients. Compression level must be between 0 - 9.';
add below:

Code: Select all

$_['help_product_new']			 	 = 'Shows new products by limited time';
$_['help_product_new_limit']		 = 'Set new products limit';
$_['help_product_new_day']			 = 'Set new product mount of days';
Then, find:

Code: Select all

$_['error_product_new_limit']		 = 'The product new limit option must be, at least, set to 1!';
$_['error_product_new_day']			 = 'The product new day option must be, at least, set to 1!';
Then, in your admin/view/template/setting/setting.twig file, find:

Code: Select all

</fieldset>
            </div>
            <div class="tab-pane" id="tab-image">
add above:

Code: Select all

<div class="form-group">
                  <label class="col-sm-2 control-label"><span data-toggle="tooltip" title="{{ help_product_new }}">{{ entry_product_new }}</span></label>
                  <div class="col-sm-10">
                    <label class="radio-inline"> {% if config_product_new %}
                      <input type="radio" name="config_product_new" value="1" checked="checked" />
                      {{ text_yes }}
                      {% else %}
                      <input type="radio" name="config_product_new" value="1" />
                      {{ text_yes }}
                      {% endif %} </label>
                    <label class="radio-inline"> {% if not config_product_new %}
                      <input type="radio" name="config_product_new" value="0" checked="checked" />
                      {{ text_no }}
                      {% else %}
                      <input type="radio" name="config_product_new" value="0" />
                      {{ text_no }}
                      {% endif %} </label>
                  </div>
                </div>
				<div class="form-group">
                  <label class="col-sm-2 control-label" for="input-product-new-limit"><span data-toggle="tooltip" title="{{ help_product_new_limit }}">{{ entry_product_new_limit }}</span></label>
                  <div class="col-sm-10">
                    <input type="text" name="config_product_new_limit" value="{{ config_product_new_limit }}" placeholder="{{ entry_product_new_limit }}" id="input-product-new-limit" class="form-control" />
					{% if error_product_new_limit %}
                      <div class="text-danger">{{ error_product_new_limit }}</div>
                    {% endif %}
                  </div>
                </div>
				<div class="form-group">
                  <label class="col-sm-2 control-label" for="input-product-new-day"><span data-toggle="tooltip" title="{{ help_product_new_day }}">{{ entry_product_new_day }}</span></label>
                  <div class="col-sm-10">
                    <input type="text" name="config_product_new_day" value="{{ config_product_new_day }}" placeholder="{{ entry_product_new_day }}" id="input-product-new-day" class="form-control" />
				  {% if error_product_new_day %}
                    <div class="text-danger">{{ error_product_new_day }}</div>
                  {% endif %}
                  </div>
                </div>
Apply the same steps for each store.php and store.twig files at the same location at the setting files from the above.

Then, in your catalog/view/theme/<your_theme>/template/extension/module/latest.twig file, between the:

Code: Select all

{% for product in products %}
and the last:

Code: Select all

{% endfor %}
you could use:

Code: Select all

{% if product.new %}
...
{% endif %}
where ... would be showing your new tag to the people for e.g .

Then, follow this FAQ: viewtopic.php?f=134&t=215776#p718325 .

Lastly, go to your OC admin - > systems - > settings - > add / edit settings - > data tab. Then, enable the new products, set your limit and day interval. This should resolved the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Thu Mar 26, 2020 8:11 pm

Added one more step in the catalog/controller/extension/module/latest.php file and switched from:

Code: Select all

$i = 0;
to:

Code: Select all

$i = 1;
on the above post.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 12 guests