Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Export Products With Popularity Field Rate Topic   - - - - -

 
  • frktprk
  • Newbie
  • Trial users
  • Join Date: 05-Aug 16
  • 7 posts

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.

 



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21562 posts

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • frktprk
  • Newbie
  • Trial users
  • Join Date: 05-Aug 16
  • 7 posts

Posted 08 August 2016 - 09:06 PM #3

Thank you so much I tried and it's really working  :grin:



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21562 posts

Posted 09 August 2016 - 07:01 AM #4

You are welcome!


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • stimminds
  • Newbie
  • Members
  • Join Date: 30-Mar 12
  • 1 posts

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!



 
  • The Tool
  • Been Here Way Too Long Member
  • Members
  • Join Date: 30-Mar 07
  • 3954 posts

Posted 01 March 2017 - 12:26 PM #6

The provided code should work for import and export.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21562 posts

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • al.valijon
  • Member
  • Members
  • Join Date: 24-Feb 17
  • 20 posts

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



 
  • The Tool
  • Been Here Way Too Long Member
  • Members
  • Join Date: 30-Mar 07
  • 3954 posts

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)


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21562 posts

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.


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)