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.
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.
- Enable the My changes module
- Create the app/addons/my_changes/schemas/exim/products.post.php
- Insert the the following code
$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:
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
Thank you so much I tried and it's really working :grin:
You are welcome!
Hi, I've just successfully implemented this to export popularity, is there a similar fix to import the popularity back in? Thanks!
The provided code should work for import and export.
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
- Enable the My changes module
- Create the app/addons/my_changes/schemas/exim/products.post.php
- Insert the the following code
$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:
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
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)
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.