Hey everybody;
When I export all products I really need to get product popularity values in the Available Filelds but there is no Popularity to choose it .
My question is how can I add the field (Popularity) in the Available Fields.
Posted 05 August 2016 - 04:23 PM #1
Hey everybody;
When I export all products I really need to get product popularity values in the Available Filelds but there is no Popularity to choose it .
My question is how can I add the field (Popularity) in the Available Fields.
Posted 08 August 2016 - 07:04 AM #2
- Enable the My changes module
- Create the app/addons/my_changes/schemas/exim/products.post.php
- Insert the the following code
<?php $schema['export_fields']['Popularity'] = array( 'linked' => false, 'process_get' => array('fn_exim_get_product_popularity', '#key'), 'process_put' => array('fn_exim_set_product_popularity', '#this', '#key') ); return $schema;
- Create the app/addons/my_changes/func.php file
- Insert the following code:
<?php use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } function fn_exim_get_product_popularity($product_id) { return db_get_field("SELECT total FROM ?:product_popularity WHERE product_id = ?i", $product_id); } function fn_exim_set_product_popularity($value, $product_id) { db_query("UPDATE ?:product_popularity SET total = ?i WHERE product_id = ?i", $value, $product_id); return true; }
- Clear cache
- Check result
(!) Not tested
Posted 09 August 2016 - 07:01 AM #4
You are welcome!
Posted 01 March 2017 - 12:07 PM #5
Hi, I've just successfully implemented this to export popularity, is there a similar fix to import the popularity back in? Thanks!
Posted 01 March 2017 - 02:07 PM #7
Hi, I've just successfully implemented this to export popularity, is there a similar fix to import the popularity back in? Thanks!
It should work. After the changes are made, do not forget to clear system cache
Posted 05 August 2017 - 05:25 PM #8
- Enable the My changes module
- Create the app/addons/my_changes/schemas/exim/products.post.php
- Insert the the following code
<?php $schema['export_fields']['Popularity'] = array( 'linked' => false, 'process_get' => array('fn_exim_get_product_popularity', '#key'), 'process_put' => array('fn_exim_set_product_popularity', '#this', '#key') ); return $schema;- Create the app/addons/my_changes/func.php file
- Insert the following code:
<?php use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } function fn_exim_get_product_popularity($product_id) { return db_get_field("SELECT total FROM ?:product_popularity WHERE product_id = ?i", $product_id); } function fn_exim_set_product_tags($value, $product_id) { db_query("UPDATE ?:product_popularity SET total = ?i WHERE product_id = ?i", $value, $product_id); return true; }- Clear cache
- Check result
(!) Not tested
eComLabs, thanks for your activity on this forum
i've tried this solution on cs-cart v4.5.2sp2 for export is working, but for import no results. After importing value of popularity is not changing
Posted 06 August 2017 - 06:04 PM #9
There is a mistake in the provided code for the import function.
This
function fn_exim_set_product_tags($value, $product_id)
Should be
function fn_exim_set_product_popularity($value, $product_id)
Posted 07 August 2017 - 06:41 AM #10
There is a mistake in the provided code for the import function.
This
function fn_exim_set_product_tags($value, $product_id)Should be
function fn_exim_set_product_popularity($value, $product_id)
Post corrected. Thank you.