Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f66dbe42c | |||
| 4e720c5689 |
@@ -780,118 +780,6 @@ class IntegrationsRepository
|
||||
return [ 'success' => true, 'message' => 'Produkt został zaimportowany.' ];
|
||||
}
|
||||
|
||||
// ── ShopPRO export ──────────────────────────────────────────
|
||||
|
||||
public function shopproExportProduct( int $productId ): array
|
||||
{
|
||||
$settings = $this->getSettings( 'shoppro' );
|
||||
$missingSetting = $this->missingShopproSetting( $settings, [ 'db_name', 'db_host', 'db_user' ] );
|
||||
if ( $missingSetting !== null ) {
|
||||
return [ 'success' => false, 'message' => 'Brakuje konfiguracji shopPRO: ' . $missingSetting . '.' ];
|
||||
}
|
||||
|
||||
$product = $this->db->get( 'pp_shop_products', '*', [ 'id' => $productId ] );
|
||||
if ( !$product ) {
|
||||
return [ 'success' => false, 'message' => 'Nie znaleziono produktu do eksportu.' ];
|
||||
}
|
||||
|
||||
$mdb2 = $this->shopproDb( $settings );
|
||||
|
||||
$mdb2->insert( 'pp_shop_products', [
|
||||
'price_netto' => $product['price_netto'] ?? null,
|
||||
'price_brutto' => $product['price_brutto'] ?? null,
|
||||
'vat' => $product['vat'] ?? null,
|
||||
'stock_0_buy' => $product['stock_0_buy'] ?? 0,
|
||||
'quantity' => $product['quantity'] ?? 0,
|
||||
'wp' => $product['wp'] ?? null,
|
||||
'sku' => $product['sku'] ?? '',
|
||||
'ean' => $product['ean'] ?? '',
|
||||
'custom_label_0' => $product['custom_label_0'] ?? null,
|
||||
'custom_label_1' => $product['custom_label_1'] ?? null,
|
||||
'custom_label_2' => $product['custom_label_2'] ?? null,
|
||||
'custom_label_3' => $product['custom_label_3'] ?? null,
|
||||
'custom_label_4' => $product['custom_label_4'] ?? null,
|
||||
'additional_message' => $product['additional_message'] ?? 0,
|
||||
'additional_message_text' => $product['additional_message_text'] ?? null,
|
||||
'additional_message_required'=> $product['additional_message_required'] ?? 0,
|
||||
'weight' => $product['weight'] ?? null,
|
||||
'producer_id' => $product['producer_id'] ?? null,
|
||||
] );
|
||||
|
||||
$newProductId = (int) $mdb2->id();
|
||||
if ( $newProductId <= 0 ) {
|
||||
return [ 'success' => false, 'message' => 'Podczas eksportowania produktu wystąpił błąd.' ];
|
||||
}
|
||||
|
||||
$languages = $this->db->select( 'pp_shop_products_langs', '*', [ 'product_id' => $productId ] );
|
||||
if ( is_array( $languages ) ) {
|
||||
foreach ( $languages as $lang ) {
|
||||
$mdb2->insert( 'pp_shop_products_langs', [
|
||||
'product_id' => $newProductId,
|
||||
'lang_id' => $lang['lang_id'] ?? '',
|
||||
'name' => $lang['name'] ?? '',
|
||||
'short_description' => $lang['short_description'] ?? null,
|
||||
'description' => $lang['description'] ?? null,
|
||||
'tab_name_1' => $lang['tab_name_1'] ?? null,
|
||||
'tab_description_1' => $lang['tab_description_1'] ?? null,
|
||||
'tab_name_2' => $lang['tab_name_2'] ?? null,
|
||||
'tab_description_2' => $lang['tab_description_2'] ?? null,
|
||||
'meta_title' => $lang['meta_title'] ?? null,
|
||||
'meta_description' => $lang['meta_description'] ?? null,
|
||||
'meta_keywords' => $lang['meta_keywords'] ?? null,
|
||||
'seo_link' => $lang['seo_link'] ?? null,
|
||||
'copy_from' => $lang['copy_from'] ?? null,
|
||||
'warehouse_message_zero' => $lang['warehouse_message_zero'] ?? null,
|
||||
'warehouse_message_nonzero'=> $lang['warehouse_message_nonzero'] ?? null,
|
||||
'canonical' => $lang['canonical'] ?? null,
|
||||
'xml_name' => $lang['xml_name'] ?? null,
|
||||
'security_information' => $lang['security_information'] ?? null,
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
$customFields = $this->db->select( 'pp_shop_products_custom_fields', '*', [ 'id_product' => $productId ] );
|
||||
if ( is_array( $customFields ) ) {
|
||||
foreach ( $customFields as $field ) {
|
||||
$mdb2->insert( 'pp_shop_products_custom_fields', [
|
||||
'id_product' => $newProductId,
|
||||
'name' => (string)($field['name'] ?? ''),
|
||||
'type' => (string)($field['type'] ?? 'text'),
|
||||
'is_required' => !empty( $field['is_required'] ) ? 1 : 0,
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
$images = $this->db->select( 'pp_shop_products_images', '*', [ 'product_id' => $productId ] );
|
||||
if ( is_array( $images ) && count( $images ) > 0 ) {
|
||||
$missingImageApiSetting = $this->missingShopproSetting( $settings, [ 'domain', 'api_key' ] );
|
||||
if ( $missingImageApiSetting !== null ) {
|
||||
return [ 'success' => false, 'message' => 'Brakuje konfiguracji shopPRO dla wysylki zdjec: ' . $missingImageApiSetting . '.' ];
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array( $images ) ) {
|
||||
foreach ( $images as $image ) {
|
||||
$remoteImageSrc = $this->sendImageToShopproApi(
|
||||
(string)($image['src'] ?? ''),
|
||||
(int)$newProductId,
|
||||
(string)($settings['domain'] ?? ''),
|
||||
(string)($settings['api_key'] ?? ''),
|
||||
(string)($image['alt'] ?? ''),
|
||||
(int)($image['o'] ?? 0)
|
||||
);
|
||||
if ( $remoteImageSrc === '' ) {
|
||||
return [ 'success' => false, 'message' => 'Nie udalo sie wyslac zdjec produktu przez API shopPRO.' ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'Produkt został wyeksportowany (ID: ' . $newProductId . ').',
|
||||
];
|
||||
}
|
||||
|
||||
private function missingShopproSetting( array $settings, array $requiredKeys ): ?string
|
||||
{
|
||||
foreach ( $requiredKeys as $requiredKey ) {
|
||||
@@ -915,79 +803,4 @@ class IntegrationsRepository
|
||||
] );
|
||||
}
|
||||
|
||||
private function sendImageToShopproApi(
|
||||
string $src,
|
||||
int $remoteProductId,
|
||||
string $remoteDomain,
|
||||
string $apiKey,
|
||||
string $alt,
|
||||
int $position
|
||||
): string
|
||||
{
|
||||
$src = trim( $src );
|
||||
if ( $src === '' ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$localSourcePath = '..' . $src;
|
||||
if ( !is_file( $localSourcePath ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$content = @file_get_contents( $localSourcePath );
|
||||
if ( $content === false ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$remoteDomain = trim( $remoteDomain );
|
||||
if ( $remoteDomain === '' ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( strpos( $remoteDomain, 'http://' ) !== 0 && strpos( $remoteDomain, 'https://' ) !== 0 ) {
|
||||
$remoteDomain = 'https://' . $remoteDomain;
|
||||
}
|
||||
$remoteDomain = rtrim( $remoteDomain, '/' );
|
||||
|
||||
$url = $remoteDomain . '/api.php?endpoint=products&action=upload_image';
|
||||
$payload = [
|
||||
'id' => $remoteProductId,
|
||||
'file_name' => basename( $src ),
|
||||
'content_base64' => base64_encode( $content ),
|
||||
'alt' => $alt,
|
||||
'o' => $position,
|
||||
];
|
||||
|
||||
$ch = curl_init( $url );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_POST, true );
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $payload, JSON_UNESCAPED_UNICODE ) );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json',
|
||||
'X-Api-Key: ' . $apiKey,
|
||||
] );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
|
||||
$response = curl_exec( $ch );
|
||||
|
||||
if ( curl_errno( $ch ) ) {
|
||||
curl_close( $ch );
|
||||
return '';
|
||||
}
|
||||
|
||||
$httpCode = (int) curl_getinfo( $ch, CURLINFO_HTTP_CODE );
|
||||
curl_close( $ch );
|
||||
|
||||
if ( $httpCode >= 400 || $response === false ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$responseData = json_decode( (string) $response, true );
|
||||
if ( !is_array( $responseData ) || ( $responseData['status'] ?? '' ) !== 'ok' ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return (string)($responseData['data']['src'] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,6 +682,7 @@ class ProductRepository
|
||||
'tab_name_2' => $lang['tab_name_2'],
|
||||
'tab_description_2' => $lang['tab_description_2'],
|
||||
'canonical' => $lang['canonical'],
|
||||
'security_information' => $lang['security_information'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -733,6 +734,10 @@ class ProductRepository
|
||||
}
|
||||
}
|
||||
|
||||
// Custom fields (Dodatkowe pola)
|
||||
$customFields = $this->db->select('pp_shop_products_custom_fields', ['name', 'type', 'is_required'], ['id_product' => $id]);
|
||||
$result['custom_fields'] = is_array($customFields) ? $customFields : [];
|
||||
|
||||
// Variants (only for parent products)
|
||||
if (empty($product['parent_id'])) {
|
||||
$result['variants'] = $this->findVariantsForApi($id);
|
||||
|
||||
@@ -265,16 +265,6 @@ class IntegrationsController
|
||||
exit;
|
||||
}
|
||||
|
||||
public function shoppro_product_export(): void
|
||||
{
|
||||
$productId = (int) \Shared\Helpers\Helpers::get( 'product_id' );
|
||||
$result = $this->repository->shopproExportProduct( $productId );
|
||||
|
||||
\Shared\Helpers\Helpers::alert( (string)($result['message'] ?? 'Wystapil blad podczas eksportu produktu.') );
|
||||
header( 'Location: /admin/shop_product/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
private function fetchApiloListWithFeedback( string $type, string $label ): void
|
||||
{
|
||||
$result = $this->repository->apiloFetchListResult( $type );
|
||||
|
||||
@@ -140,14 +140,6 @@ class ShopProductController
|
||||
}
|
||||
}
|
||||
|
||||
if ( $shopproEnabled ) {
|
||||
$row['_actions'][] = [
|
||||
'label' => 'Eksportuj do shopPRO',
|
||||
'url' => '/admin/integrations/shoppro_product_export/product_id=' . $id,
|
||||
'class' => 'btn btn-xs btn-system',
|
||||
'confirm' => 'Na pewno chcesz wyeksportowac ten produkt do shopPRO?',
|
||||
];
|
||||
}
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,8 @@ Odpowiedz:
|
||||
"tab_description_1": null,
|
||||
"tab_name_2": null,
|
||||
"tab_description_2": null,
|
||||
"canonical": null
|
||||
"canonical": null,
|
||||
"security_information": null
|
||||
}
|
||||
},
|
||||
"images": [
|
||||
@@ -253,6 +254,9 @@ Odpowiedz:
|
||||
"value_names": {"pl": "Czerwony", "en": "Red"}
|
||||
}
|
||||
],
|
||||
"custom_fields": [
|
||||
{"name": "Napis na koszulce", "type": "text", "is_required": 1}
|
||||
],
|
||||
"variants": [
|
||||
{
|
||||
"id": 101,
|
||||
|
||||
@@ -229,7 +229,7 @@ class IntegrationsRepositoryTest extends TestCase
|
||||
'linkProduct', 'unlinkProduct',
|
||||
'apiloAuthorize', 'apiloGetAccessToken', 'apiloKeepalive', 'apiloIntegrationStatus',
|
||||
'apiloFetchList', 'apiloFetchListResult', 'apiloProductSearch', 'apiloCreateProduct',
|
||||
'getProductSku', 'shopproImportProduct', 'shopproExportProduct',
|
||||
'getProductSku', 'shopproImportProduct',
|
||||
];
|
||||
|
||||
foreach ($expectedMethods as $method) {
|
||||
|
||||
@@ -118,7 +118,6 @@ class IntegrationsControllerTest extends TestCase
|
||||
'shoppro_settings',
|
||||
'shoppro_settings_save',
|
||||
'shoppro_product_import',
|
||||
'shoppro_product_export',
|
||||
];
|
||||
|
||||
foreach ($methods as $method) {
|
||||
@@ -158,7 +157,6 @@ class IntegrationsControllerTest extends TestCase
|
||||
'apilo_product_select_delete',
|
||||
'shoppro_settings_save',
|
||||
'shoppro_product_import',
|
||||
'shoppro_product_export',
|
||||
];
|
||||
|
||||
foreach ($voidMethods as $method) {
|
||||
|
||||
BIN
updates/0.30/ver_0.318.zip
Normal file
BIN
updates/0.30/ver_0.318.zip
Normal file
Binary file not shown.
30
updates/0.30/ver_0.318_manifest.json
Normal file
30
updates/0.30/ver_0.318_manifest.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"changelog": "NEW - shopPRO export produktów + API endpoints (ensure_attribute, ensure_attribute_value, upload_image)",
|
||||
"version": "0.318",
|
||||
"files": {
|
||||
"added": [
|
||||
|
||||
],
|
||||
"deleted": [
|
||||
|
||||
],
|
||||
"modified": [
|
||||
"admin/templates/integrations/shoppro-settings.php",
|
||||
"autoload/Domain/Attribute/AttributeRepository.php",
|
||||
"autoload/Domain/Integrations/IntegrationsRepository.php",
|
||||
"autoload/Domain/Product/ProductRepository.php",
|
||||
"autoload/admin/Controllers/IntegrationsController.php",
|
||||
"autoload/admin/Controllers/ShopProductController.php",
|
||||
"autoload/api/Controllers/DictionariesApiController.php",
|
||||
"autoload/api/Controllers/ProductsApiController.php"
|
||||
]
|
||||
},
|
||||
"checksum_zip": "sha256:6a7eba1b390db94ccda210a5f2cbcd33f17f43d9f34031c4d0793d224df5d541",
|
||||
"sql": [
|
||||
|
||||
],
|
||||
"date": "2026-02-24",
|
||||
"directories_deleted": [
|
||||
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
<b>ver. 0.318 - 24.02.2026</b><br />
|
||||
NEW - shopPRO export produktów + API endpoints (ensure_attribute, ensure_attribute_value, upload_image)
|
||||
<hr>
|
||||
<b>ver. 0.317 - 23.02.2026</b><br />
|
||||
FIX - klucz API: fix zapisu (brakowalo w whiteliście), przycisk Generuj losowy klucz, ulepszony routing API
|
||||
FIX - klucz API: fix zapisu (brakowalo w whiteliście), przycisk Generuj losowy klucz, ulepszony routing API
|
||||
<hr>
|
||||
<b>ver. 0.316 - 23.02.2026</b><br />
|
||||
FIX - migracja brakujacej kolumny type w pp_shop_products_custom_fields
|
||||
@@ -8,16 +11,16 @@ FIX - migracja brakujacej kolumny type w pp_shop_products_custom_fields
|
||||
FIX - PDOException w listowaniu atrybutow admin (SQLSTATE HY093)
|
||||
<hr>
|
||||
<b>ver. 0.314 - 23.02.2026</b><br />
|
||||
FIX - naprawa globalnej wyszukiwarki admin (Content-Type, Cache-Control, POST, try/catch), NEW - title strony z numerem zamĂłwienia
|
||||
FIX - naprawa globalnej wyszukiwarki admin (Content-Type, Cache-Control, POST, try/catch), NEW - title strony z numerem zamĂłwienia
|
||||
<hr>
|
||||
<b>ver. 0.313 - 23.02.2026</b><br />
|
||||
FIX - sync pÄąĂË€šatnoÄąĂË€şci Apilo (int cast na apilo_order_id PPxxxxxx dawaÄąĂË€š 0) + logowanie decyzji sync do pp_log
|
||||
FIX - sync pÄąĂËÂĂ˂¬ĹˇatnoÄąĂËÂĂ˂¬Ĺźci Apilo (int cast na apilo_order_id PPxxxxxx dawaÄąĂËÂĂ˂¬Ĺˇ 0) + logowanie decyzji sync do pp_log
|
||||
<hr>
|
||||
<b>ver. 0.312 - 23.02.2026</b><br />
|
||||
FIX - krytyczne bugi integracji Apilo: curl_getinfo po curl_close, nieskoÄąĂËÂĂ˂¬Ĺľczona pÄ‚ĂË€žĂËÂĂˀžËÂÂtla wysyÄąĂËÂĂ˂¬Ĺˇki, ceny 0.00 PLN, walidacja cen
|
||||
FIX - krytyczne bugi integracji Apilo: curl_getinfo po curl_close, nieskoÄ‚ĂË€žĂ„ĂË€¦Ä‚ËÂÂÄ‚ËÂĂˀšÂ¬ÄąÄľczona pĂ„ĂË€šĂËÂĂ˂¬ĹľÄ‚ËÂÂÄ‚ËÂĂ˂¬ĹľĂ‹ÂÂÂtla wysyÄ‚ĂË€žĂ„ĂË€¦Ä‚ËÂÂÄ‚ËÂĂˀšÂ¬ÄąË‡ki, ceny 0.00 PLN, walidacja cen
|
||||
<hr>
|
||||
<b>ver. 0.311 - 23.02.2026</b><br />
|
||||
FIX - race condition callback pÄ‚ĂË€žĂ„ĂË€¦Ä‚ËÂÂÄ‚ËÂĂˀšÂ¬ÄąË‡atnoÄ‚ĂË€žĂ„ĂË€¦Ä‚ËÂÂÄ‚ËÂĂˀšÂ¬ÄąĹşci Apilo, persistence filtrÄ‚ĂË€žĂËÂĂ˂¬ĹˇĂ„Ä…ĂËÂĂ˂¬Ĺˇw tabel admin, poprawki cen zamÄ‚ĂË€žĂËÂĂ˂¬ĹˇĂ„Ä…ĂËÂĂ˂¬ĹˇwieÄ‚ĂË€žĂ„ĂË€¦Ä‚ËÂÂÄ‚ËÂĂˀšÂ¬ÄąÄľ
|
||||
FIX - race condition callback pĂ„ĂË€šĂËÂĂ˂¬ĹľÄ‚ĂË€žĂËÂĂ˂¬Â¦Ă„ĂË€šĂ‹ÂÂÂÄ‚ËÂÂÄ‚ËÂĂ˂¬ĹˇĂ‚¬ÄąËĂË€ˇatnoĂ„ĂË€šĂËÂĂ˂¬ĹľÄ‚ĂË€žĂËÂĂ˂¬Â¦Ă„ĂË€šĂ‹ÂÂÂÄ‚ËÂÂÄ‚ËÂĂ˂¬ĹˇĂ‚¬ÄąĹşci Apilo, persistence filtrĂ„ĂË€šĂËÂĂ˂¬ĹľÄ‚ËÂÂÄ‚ËÂĂˀšÂ¬ÄąË‡Ä‚ĂË€žĂ„ĂË€¦Ä‚ËÂÂÄ‚ËÂĂˀšÂ¬ÄąË‡w tabel admin, poprawki cen zamĂ„ĂË€šĂËÂĂ˂¬ĹľÄ‚ËÂÂÄ‚ËÂĂˀšÂ¬ÄąË‡Ä‚ĂË€žĂ„ĂË€¦Ä‚ËÂÂÄ‚ËÂĂˀšÂ¬ÄąË‡wieĂ„ĂË€šĂËÂĂ˂¬ĹľÄ‚ĂË€žĂËÂĂ˂¬Â¦Ă„ĂË€šĂ‹ÂÂÂÄ‚ËÂÂÄ‚ËÂĂ˂¬ĹˇĂ‚¬ÄąÄľ
|
||||
<hr>
|
||||
<b>ver. 0.310 - 23.02.2026</b><br />
|
||||
NEW - Zakladka Logi w sekcji Integracje (podglad pp_log z paginacja, sortowaniem, filtrami)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?
|
||||
$current_ver = 317;
|
||||
$current_ver = 319;
|
||||
|
||||
for ($i = 1; $i <= $current_ver; $i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user