- Created XmlFiles control class for handling XML file views and regeneration. - Implemented method to retrieve clients with XML feeds in the factory class. - Added database migration to include google_merchant_account_id in clients table. - Created migrations for products_keyword_planner_terms and products_merchant_sync_log tables. - Added campaign_keywords table migration for managing campaign keyword data. - Developed main view template for displaying XML files and their statuses. - Introduced a debug script for analyzing product URLs and their statuses.
44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
namespace factory;
|
|
|
|
class XmlFiles
|
|
{
|
|
static public function get_clients_with_xml_feed()
|
|
{
|
|
global $mdb;
|
|
|
|
$clients = $mdb -> query(
|
|
"SELECT id, name, google_ads_customer_id
|
|
FROM clients
|
|
WHERE deleted = 0
|
|
ORDER BY name ASC"
|
|
) -> fetchAll( \PDO::FETCH_ASSOC );
|
|
|
|
$rows = [];
|
|
|
|
foreach ( $clients as $client )
|
|
{
|
|
$client_id = (int) ( $client['id'] ?? 0 );
|
|
$scheme = ( !empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] !== 'off' ) ? 'https' : 'http';
|
|
$host = $_SERVER['HTTP_HOST'] ?? ( $_SERVER['SERVER_NAME'] ?? 'localhost' );
|
|
$relative_path = '/xml/custom-feed-' . $client_id . '.xml';
|
|
$absolute_url = $scheme . '://' . $host . $relative_path;
|
|
$absolute_path = dirname( __DIR__, 2 ) . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'custom-feed-' . $client_id . '.xml';
|
|
$exists = is_file( $absolute_path );
|
|
$last_modified = $exists ? date( 'Y-m-d H:i:s', (int) filemtime( $absolute_path ) ) : '';
|
|
|
|
$rows[] = [
|
|
'client_id' => $client_id,
|
|
'client_name' => (string) ( $client['name'] ?? '' ),
|
|
'google_ads_customer_id' => (string) ( $client['google_ads_customer_id'] ?? '' ),
|
|
'xml_relative_path' => $relative_path,
|
|
'xml_url' => $absolute_url,
|
|
'xml_exists' => $exists,
|
|
'xml_last_modified' => $last_modified
|
|
];
|
|
}
|
|
|
|
return $rows;
|
|
}
|
|
}
|