Skip to content

Instantly share code, notes, and snippets.

@anoriar
anoriar / deliveryService.php
Created July 3, 2019 22:27
guzzle request
namespace Shell\Service;
use GuzzleHttp\Exception\ClientException;
use Psr\Log\LoggerInterface;
class DeliveryService
{
private $logger;
$ftpPath = trim(\Bitrix\Main\Config\Option::get("grain.customsettings","ftp_path"), '/');
$rs = FileTable::getList([
'filter' => ['ID' => $lastProduct['PROPERTY_IMAGES_VALUE']],
'select' => ['ID', 'SUBDIR', 'ORIGINAL_NAME', 'FILE_NAME'],
]);
while ($fileInfo = $rs->Fetch()) {
$newFileName = str_replace($lastProduct['CODE'], $modelCode, $fileInfo['ORIGINAL_NAME']);
copy($_SERVER["DOCUMENT_ROOT"] . $ftpPath . '/' . $newFileName, $_SERVER["DOCUMENT_ROOT"] . 'upload/' . $fileInfo['SUBDIR'] . '/' . $fileInfo['FILE_NAME']);
$filesTable[$fileInfo["ID"]] = $fileInfo;
}
@anoriar
anoriar / import.php
Created April 26, 2019 10:23
elastic index all + sort by cities
protected function indexModels($arFilter, $indexToReindex = false, $deleteNotExistsOffers = false)
{
if ($indexToReindex) {
$index = $indexToReindex;
} else {
$index = $this->index;
}
// получим товары
$arModels = $this->getModels($arFilter);
@anoriar
anoriar / module.php
Last active April 15, 2019 11:21
search reindex
На всякий случай:
http://epages.su/blog/dobavlenie-v-rezultat-poiska-1s-bitriks-neaktivnye-elementy-infobloka.html
https://bxapi.ru/src/?module_id=iblock&name=CIBlock%3A%3AOnSearchReindex
$entity = \Bitrix\Iblock\Model\Section::compileEntityByIblock(IB_Catalog);
$section = $entity::getList(array(
'select' =>
[
'ID',
'CODE',
'IBLOCK_ID',
'DETAIL_PICTURE',
'PICTURE',
'UF_ICON',
Array
(
[index] => products
[type] => models
[sort] => Array
(
[0] => SORT:desc
)
[body] => Array
$offerId = 1648187;
$productId = 2758189;
CIBlockElement::SetPropertyValuesEx($offerId, IB_TradeOffers, array("SKU_PROPERTY_ID" => $productId));
use Bitrix\Main\Entity\Event;
use Aero\Tools\Module;
public static function onAfterUpdate(Event $event)
{
\BXClearCache();
}
@anoriar
anoriar / csv
Created January 24, 2019 21:43
function getCsvData($fileName)
{
$fp = fopen($fileName, 'r');
$head = fgetcsv($fp, 4096, ';', '"');
$res = array();
$counter = 1;
while ($column = fgetcsv($fp, 0, ';', '"')) {
$counter++;
$column = array_combine($head, $column);
$res[] = $column;
$db_sales = CSaleOrder::GetList(array("DATE_INSERT" => "ASC"), $arFilter, false, ["nTopCount" => 1], ["ID", "STATUS_ID"]);
if($sale = $db_sales->Fetch())
{
$lastOrderId = $sale["ID"];
$arProps = array();
$orderProps = CSaleOrderPropsValue::GetList(
[],
array(
"ORDER_ID" => $lastOrderId,
"CODE" => ["DELIVERY_SHOP_ID"]