Answer the question
In order to leave comments, you need to log in
Why does file_put_contents() work strangely in Bitrix?
Catalog export script example
$arSelect = [
'ID', 'IBLOCK_ID','IBLOCK_CODE','IBLOCK_SECTION_ID','NAME', 'LIST_PAGE_URL', 'DETAIL_TEXT', 'DETAIL_PICTURE', 'DETAIL_PAGE_URL', 'SECTION_PAGE_URL',
'PROPERTY_CML2_ARTICLE','PROPERTY_MODEL','PROPERTY_BRAND', 'PROPERTY_GABARITY_VKHSHKHG_SM'
];
$arFilter = Array(
"IBLOCK_ID"=> $iblockId,
'!IBLOCK_SECTION_ID' => SECTION_NEMATRITSA_ID,
"PROPERTY_COPY_PROPERTIES" => 1,
);
$res = \CIBlockElement::GetList(Array('IBLOCK_SECTION_ID'=>'ASC', 'PROPERT_BRAND_VALUE' => 'ASC'), $arFilter, false, false, $arSelect);
$arElements = [];
$i = 0;
while($ob = $res->GetNextElement()) {
$fields = $ob->GetFields();
$fields['PRODUCT_INFO'] = CCatalogProduct::GetByID($fields['ID']);
if ($fields["~DETAIL_PICTURE"] != null) {
$resizeImage = CFile::ResizeImageGet(
$fields["~DETAIL_PICTURE"],
array("width" => 150, "height" => 150),
BX_RESIZE_IMAGE_PROPORTIONAL,
true
);
if (!$resizeImage) {
$fields['DETAIL_PICTURE'] = '/local/templates/eshop_bootstrap_black/components/bitrix/catalog.element/.default/images/no_photo.png';
} else {
$fields['DETAIL_PICTURE'] = $resizeImage['src'];
}
$fields['IMAGE_PATH'] = $_SERVER["DOCUMENT_ROOT"] . $fields['DETAIL_PICTURE'];
} else {
$fields['IMAGE_PATH'] = $_SERVER["DOCUMENT_ROOT"] . '/local/templates/eshop_bootstrap_black/components/bitrix/catalog.element/quick-view/images/no_photo.png';
}
$arElements[] = $fields;
file_put_contents('test.csv', $fields['IMAGE_PATH'] . "\r\n", FILE_APPEND);
$i++;
}
$resizeImage = CFile::ResizeImageGet(
$fields["~DETAIL_PICTURE"],
array("width" => 150, "height" => 150),
BX_RESIZE_IMAGE_PROPORTIONAL,
true
);
Answer the question
In order to leave comments, you need to log in
And what are the characteristics of a virtual machine? Maybe there is not enough memory in the buffer during generation?
In general, it is preferable to use spl-objects. Here is your
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question