1
0
mirror of synced 2024-11-21 21:06:09 +03:00

CDN correct url in icml

This commit is contained in:
Alex Lushpai 2021-01-15 14:45:40 +03:00 committed by GitHub
commit 1d2a9dca82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 14 deletions

View File

@ -1,3 +1,8 @@
## 2021-01-14 v.5.6.2
* Исправлено формирование картинок в ICML при включеном CDN
* Убрана некорректная запись внешнего идентификатора платежа для новых платежей по истории
* Добавлена проверка на длину email при отправке в систему
## 2020-12-15 v.5.6.1
* Обновлено наименование бренда

View File

@ -257,11 +257,11 @@ class RetailCrmICML
. "<name>" . $this->PrepareValue($arCategory["NAME"]) . "</name>\n";
if (CFile::GetPath($arCategory["DETAIL_PICTURE"])) {
$category .= "\t<picture>" . $arCategory['SITE'] . CFile::GetPath($arCategory["DETAIL_PICTURE"]) . "</picture>\n";
$category .= "\t<picture>" . $this->getImageUrl($arCategory["DETAIL_PICTURE"]) . "</picture>\n";
}
if (CFile::GetPath($arCategory["PICTURE"])) {
$category .= "\t<picture>" . $arCategory['SITE'] . CFile::GetPath($arCategory["PICTURE"]) . "</picture>\n";
$category .= "\t<picture>" . $this->getImageUrl($arCategory["PICTURE"]) . "</picture>\n";
}
$category .= "</category>\n";
@ -421,16 +421,15 @@ class RetailCrmICML
$offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"];
if (CFile::GetPath($offer["DETAIL_PICTURE"])) {
$offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["DETAIL_PICTURE"]);
} elseif (CFile::GetPath($offer["PREVIEW_PICTURE"])){
$offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["PREVIEW_PICTURE"]);
$offer['PICTURE'] = $this->getImageUrl($offer["DETAIL_PICTURE"]);
} elseif (CFile::GetPath($offer["PREVIEW_PICTURE"])) {
$offer['PICTURE'] = $this->getImageUrl($offer["PREVIEW_PICTURE"]);
} elseif (
$this->skuPictures
&& isset($this->skuPictures[$iblockId])
&& CFile::GetPath($offer["PROPERTY_" . $this->skuPictures[$iblockId]['picture'] . "_VALUE"])
) {
$picture = CFile::GetPath($offer["PROPERTY_" . $this->skuPictures[$iblockId]['picture'] . "_VALUE"]);
$offer['PICTURE'] = $this->protocol . $this->serverName . $picture;
$offer['PICTURE'] = $this->getImageUrl($offer["PROPERTY_" . $this->skuPictures[$iblockId]['picture'] . "_VALUE"]);
} else {
$offer['PICTURE'] = $product['PICTURE'];
}
@ -502,16 +501,15 @@ class RetailCrmICML
$picture = '';
if (CFile::GetPath($product["DETAIL_PICTURE"])) {
$picture = $this->protocol . $this->serverName . CFile::GetPath($product["DETAIL_PICTURE"]);
$picture = $this->getImageUrl($product["DETAIL_PICTURE"]);
} elseif (CFile::GetPath($product["PREVIEW_PICTURE"])){
$picture= $this->protocol . $this->serverName . CFile::GetPath($product["PREVIEW_PICTURE"]);
$picture = $this->getImageUrl($product["PREVIEW_PICTURE"]);
} elseif (
$this->productPictures
&& isset($this->productPictures[$iblockId])
&& CFile::GetPath($product["PROPERTY_" . $this->productPictures[$iblockId]['picture'] . "_VALUE"])
) {
$file = CFile::GetPath($product["PROPERTY_" . $this->productPictures[$iblockId]['picture'] . "_VALUE"]);
$picture = $this->protocol . $this->serverName . $file;
$picture = $this->getImageUrl($product["PROPERTY_" . $this->productPictures[$iblockId]['picture'] . "_VALUE"]);
}
return $picture;
@ -894,4 +892,20 @@ class RetailCrmICML
"picture" => GetMessage("PROPERTY_PICTURE_HEADER_NAME")
);
}
/**
* @param $fileId
* @return string
*/
public function getImageUrl($fileId)
{
$pathImage = CFile::GetPath($fileId);
$validation = "/^(http|https):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i";
if ((bool)preg_match($validation, $pathImage) === false) {
return $this->protocol . $this->serverName . $pathImage;
} else {
return $pathImage;
}
}
}

View File

@ -1 +1,3 @@
- Обновлено наименование бренда
- Исправлено формирование картинок в ICML при включеном CDN
- Убрана некорректная запись внешнего идентификатора платежа для новых платежей по истории
- Добавлена проверка на длину email при отправке в систему

View File

@ -1,5 +1,5 @@
<?
$arModuleVersion = array(
"VERSION" => "5.6.1",
"VERSION_DATE" => "2020-12-15 12:00:00"
"VERSION" => "5.6.2",
"VERSION_DATE" => "2021-01-14 16:00:00"
);

View File

@ -31,4 +31,10 @@ if (!IsModuleInstalled('intaro.retailcrm')) {
COption::SetOptionString('intaro.retailcrm', 'api_version', 'v5');
CModule::IncludeModule('intaro.retailcrm');
CModule::IncludeModule("main");
global $DB;
$strSql = "INSERT INTO b_file (TIMESTAMP_X, MODULE_ID, HEIGHT, WIDTH, FILE_SIZE, CONTENT_TYPE, SUBDIR, FILE_NAME, ORIGINAL_NAME, DESCRIPTION, HANDLER_ID, EXTERNAL_ID)
VALUES ('2020-05-08 19:04:03', 'iblock', '500', '500', '23791', 'image/jpeg', 'iblock/c44', 'test.jpg', '788c4cf58bd93a5f75f2e3f2034023db.jpg', '', '', 'c570f175b3f74ccfa62c4a10d8e44b5c');";
$DB->Query($strSql);
require_once 'BitrixTestCase.php';

View File

@ -0,0 +1,37 @@
<?php
/**
* Class RetailCrmOrderTest
*/
use \Bitrix\Main\Loader;
class RetailCrmICMLTest extends BitrixTestCase
{
/**
* @inheritdoc
*/
public function setUp()
{
parent::setUp();
COption::SetOptionString('intaro.retailcrm', 'api_version', 'v5');
CModule::IncludeModule('intaro.retailcrm');
}
public function testModuleInstalled()
{
$this->assertTrue(Loader::includeModule("intaro.retailcrm"));
}
public function testGetImageUrl()
{
$test = new RetailCrmICML();
$result = $test->getImageUrl(1);
if (!empty($result)) {
$this->assertIsString($result);
$this->assertEquals("/upload/iblock/c44/test.jpg", $result);
} else {
$this->assertEmpty($result);
}
}
}