|
6 | 6 |
|
7 | 7 | use Bigcommerce\Api\Client;
|
8 | 8 | use BigCommerce\Api\Store_Api;
|
| 9 | +use BigCommerce\Api\v3\Api\SettingsApi; |
9 | 10 | use BigCommerce\Api\v3\ApiException;
|
10 | 11 | use BigCommerce\Import\Runner\Status;
|
11 | 12 | use BigCommerce\Logging\Error_Log;
|
12 | 13 | use BigCommerce\Post_Types\Product\Product;
|
13 | 14 | use BigCommerce\Settings;
|
| 15 | +use BigCommerce\Taxonomies\Channel\Channel; |
| 16 | +use BigCommerce\Taxonomies\Channel\Connections; |
14 | 17 |
|
15 | 18 | class Store_Settings implements Import_Processor {
|
16 | 19 |
|
@@ -39,8 +42,14 @@ class Store_Settings implements Import_Processor {
|
39 | 42 | */
|
40 | 43 | private $storefront_processor;
|
41 | 44 |
|
42 |
| - public function __construct( Store_Api $store_api, Default_Customer_Group $default_customer_group, Storefront_Processor $storefront_processor ) { |
| 45 | + /** |
| 46 | + * @var \BigCommerce\Api\v3\Api\SettingsApi |
| 47 | + */ |
| 48 | + private $api_v3; |
| 49 | + |
| 50 | + public function __construct( Store_Api $store_api, Default_Customer_Group $default_customer_group, Storefront_Processor $storefront_processor, SettingsApi $api ) { |
43 | 51 | $this->store_api = $store_api;
|
| 52 | + $this->api_v3 = $api; |
44 | 53 | $this->default_customer_group = $default_customer_group;
|
45 | 54 | $this->storefront_processor = $storefront_processor;
|
46 | 55 | }
|
@@ -75,9 +84,16 @@ public function run() {
|
75 | 84 | ];
|
76 | 85 |
|
77 | 86 | if ( get_option( Settings\Sections\Analytics::SYNC_ANALYTICS, 1 ) ) {
|
78 |
| - $analytics = $this->store_api->get_analytics_settings(); |
79 |
| - $settings[ Settings\Sections\Analytics::FACEBOOK_PIXEL ] = $this->extract_facebook_pixel_id( $analytics ); |
80 |
| - $settings[ Settings\Sections\Analytics::GOOGLE_ANALYTICS ] = $this->extract_google_analytics_id( $analytics ); |
| 87 | + $connections = new Connections(); |
| 88 | + $channel = $connections->current(); |
| 89 | + $analytics = $this->api_v3->getStoreAnalyticsSettings( (int) get_term_meta( $channel->term_id, Channel::CHANNEL_ID, true )); |
| 90 | + |
| 91 | + if ( ! empty( $analytics->data ) ) { |
| 92 | + $analytics = json_decode( json_encode( $analytics->data ), true ); |
| 93 | + $settings[ Settings\Sections\Analytics::FACEBOOK_PIXEL ] = $this->extract_facebook_pixel_id( $analytics ); |
| 94 | + $settings[ Settings\Sections\Analytics::GOOGLE_ANALYTICS ] = $this->extract_google_analytics_id( $analytics ); |
| 95 | + } |
| 96 | + |
81 | 97 | }
|
82 | 98 |
|
83 | 99 | do_action( 'bigcommerce/log', Error_Log::DEBUG, __( 'Retrieved store settings', 'bigcommerce' ), [
|
|
0 commit comments