Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
->in(__DIR__ . '/src/Services/SonetGroup/')
->in(__DIR__ . '/src/Services/IMOpenLines/')
->in(__DIR__ . '/src/Services/Landing/')
->in(__DIR__ . '/src/Services/Catalog/')
->name('*.php')
->exclude(['vendor', 'storage', 'docker', 'docs']) // Exclude directories
->ignoreDotFiles(true)
Expand Down
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,40 @@

### Added

- Added `update` and `download` methods to `Services\Catalog\Product\Service\Product` for
`catalog.product.update` / `catalog.product.download`,
see [catalog.product.* methods](https://apidocs.bitrix24.com/api-reference/catalog/product/index.html) ([#527](https://github.com/bitrix24/b24phpsdk/issues/527))
- Added service `Services\Catalog\Product\ProductService\Service\ProductService` with support for
`catalog.product.service.*` methods,
see [catalog.product.service.* methods](https://apidocs.bitrix24.com/api-reference/catalog/product/service/index.html) ([#527](https://github.com/bitrix24/b24phpsdk/issues/527)):
- `add` creates a new service
- `update` updates an existing service
- `get` gets information about the service by its identifier
- `list` gets the list of services by filter
- `delete` deletes a service
- `fieldsByFilter` returns service field descriptions by iblock filter (`catalog.product.service.getFieldsByFilter`)
- `download` downloads a service file
- Added service `Services\Catalog\Product\Sku\Service\Sku` with support for `catalog.product.sku.*`
methods,
see [catalog.product.sku.* methods](https://apidocs.bitrix24.com/api-reference/catalog/product/sku/index.html) ([#527](https://github.com/bitrix24/b24phpsdk/issues/527)):
- `add` creates a new parent (SKU) product
- `update` updates an existing parent product
- `get` gets information about the parent product by its identifier
- `list` gets the list of parent products by filter
- `delete` deletes a parent product
- `fieldsByFilter` returns parent product field descriptions by iblock filter (`catalog.product.sku.getFieldsByFilter`)
- `download` downloads a parent product file
- Added service `Services\Catalog\Product\Offer\Service\Offer` with support for
`catalog.product.offer.*` methods,
see [catalog.product.offer.* methods](https://apidocs.bitrix24.com/api-reference/catalog/product/offer/index.html) ([#527](https://github.com/bitrix24/b24phpsdk/issues/527)):
- `add` creates a new product variation (offer)
- `update` updates an existing product variation
- `get` gets information about the product variation by its identifier
- `list` gets the list of product variations by filter
- `delete` deletes a product variation
- `fieldsByFilter` returns product variation field descriptions by iblock filter (`catalog.product.offer.getFieldsByFilter`)
- `download` downloads a product variation file

- Added service `Services\Landing\Site\Service\Site` with support methods,
see [landing.site.* methods](https://github.com/bitrix24/b24phpsdk/issues/267):
- `add` adds a site
Expand Down Expand Up @@ -156,6 +190,11 @@
All classes under `Bitrix24\SDK\Legacy\` are marked `@deprecated` and will be removed
once v3 reaches feature parity with v1.

### Fixed

- Fixed `Services\Catalog\Catalog\Result\CatalogsResult::getCatalogs()` returning `ProductItemResult`
instances instead of `CatalogItemResult` ([#527](https://github.com/bitrix24/b24phpsdk/issues/527))

## 3.0.0 - 2026.01.01

### Added
Expand Down
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ help:
@echo "test-integration-landing-role - run Landing Role integration tests"
@echo "test-integration-landing-repowidget - run Landing RepoWidget integration tests"
@echo "test-integration-scope-landing-template - run Landing Template integration tests"
@echo "test-integration-scope-catalog - run Catalog scope integration tests"
@echo "test-integration-catalog-catalog - run Catalog Catalog integration tests"
@echo "test-integration-catalog-product - run Catalog Product integration tests"
@echo "test-integration-catalog-product-service - run Catalog ProductService integration tests"
@echo "test-integration-catalog-product-sku - run Catalog Product Sku integration tests"
@echo "test-integration-catalog-product-offer - run Catalog Product Offer integration tests"


.PHONY: docker-init
Expand Down Expand Up @@ -492,6 +498,30 @@ test-integration-landing-role:
test-integration-landing-repowidget:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_landing_repowidget

.PHONY: test-integration-scope-catalog
test-integration-scope-catalog:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_catalog

.PHONY: test-integration-catalog-catalog
test-integration-catalog-catalog:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_catalog_catalog

.PHONY: test-integration-catalog-product
test-integration-catalog-product:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_catalog_product

.PHONY: test-integration-catalog-product-service
test-integration-catalog-product-service:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_catalog_product_service

.PHONY: test-integration-catalog-product-sku
test-integration-catalog-product-sku:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_catalog_product_sku

.PHONY: test-integration-catalog-product-offer
test-integration-catalog-product-offer:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_catalog_product_offer

# work dev environment
.PHONY: php-dev-server-up
php-dev-server-up:
Expand Down
21 changes: 21 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,27 @@
<testsuite name="integration_tests_landing_repowidget">
<directory>./tests/Integration/Services/Landing/RepoWidget/</directory>
</testsuite>
<testsuite name="integration_tests_scope_catalog">
<directory>./tests/Integration/Services/Catalog/</directory>
</testsuite>
<testsuite name="integration_tests_catalog_catalog">
<file>./tests/Integration/Services/Catalog/Catalog/Service/CatalogTest.php</file>
</testsuite>
<testsuite name="integration_tests_catalog_product">
<file>./tests/Integration/Services/Catalog/Product/Service/ProductTest.php</file>
</testsuite>
<testsuite name="integration_tests_catalog_product_service">
<file>./tests/Integration/Services/Catalog/Product/ProductService/Service/ProductServiceTest.php</file>
<file>./tests/Integration/Services/Catalog/Product/ProductService/Result/ProductServiceItemResultTest.php</file>
</testsuite>
<testsuite name="integration_tests_catalog_product_sku">
<file>./tests/Integration/Services/Catalog/Product/Sku/Service/SkuTest.php</file>
<file>./tests/Integration/Services/Catalog/Product/Sku/Result/SkuItemResultTest.php</file>
</testsuite>
<testsuite name="integration_tests_catalog_product_offer">
<file>./tests/Integration/Services/Catalog/Product/Offer/Service/OfferTest.php</file>
<file>./tests/Integration/Services/Catalog/Product/Offer/Result/OfferItemResultTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Catalog/Catalog/Result/CatalogItemResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
*/
class CatalogItemResult extends AbstractCatalogItem
{
}
}
2 changes: 1 addition & 1 deletion src/Services/Catalog/Catalog/Result/CatalogResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public function catalog(): CatalogItemResult
{
return new CatalogItemResult($this->getCoreResponse()->getResponseData()->getResult()['catalog']);
}
}
}
9 changes: 4 additions & 5 deletions src/Services/Catalog/Catalog/Result/CatalogsResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@

use Bitrix24\SDK\Core\Exceptions\BaseException;
use Bitrix24\SDK\Core\Result\AbstractResult;
use Bitrix24\SDK\Services\Catalog\Product\Result\ProductItemResult;

class CatalogsResult extends AbstractResult
{
/**
* @return ProductItemResult[]
* @return CatalogItemResult[]
* @throws BaseException
*/
public function getCatalogs(): array
{
$res = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult()['catalogs'] as $product) {
$res[] = new ProductItemResult($product);
foreach ($this->getCoreResponse()->getResponseData()->getResult()['catalogs'] as $catalog) {
$res[] = new CatalogItemResult($catalog);
}

return $res;
}
}
}
2 changes: 1 addition & 1 deletion src/Services/Catalog/Catalog/Service/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ public function fields(): FieldsResult
{
return new FieldsResult($this->core->call('catalog.catalog.getFields'));
}
}
}
43 changes: 40 additions & 3 deletions src/Services/Catalog/CatalogServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@
use Bitrix24\SDK\Core\Credentials\Scope;
use Bitrix24\SDK\Services\AbstractServiceBuilder;
use Bitrix24\SDK\Services\Catalog;

#[ApiServiceBuilderMetadata(new Scope(['catalog']))]
class CatalogServiceBuilder extends AbstractServiceBuilder
{
public function catalog(): Catalog\Catalog\Service\Catalog
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Catalog\Catalog\Service\Catalog(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

public function product(): Catalog\Product\Service\Product
{
if (!isset($this->serviceCache[__METHOD__])) {
Expand All @@ -33,15 +46,39 @@ public function product(): Catalog\Product\Service\Product
return $this->serviceCache[__METHOD__];
}

public function catalog(): Catalog\Catalog\Service\Catalog
public function productService(): Catalog\Product\ProductService\Service\ProductService
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Catalog\Catalog\Service\Catalog(
$this->serviceCache[__METHOD__] = new Catalog\Product\ProductService\Service\ProductService(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

public function productSku(): Catalog\Product\Sku\Service\Sku
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Catalog\Product\Sku\Service\Sku(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

public function productOffer(): Catalog\Product\Offer\Service\Offer
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Catalog\Product\Offer\Service\Offer(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}
}
}
4 changes: 3 additions & 1 deletion src/Services/Catalog/Common/ProductType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ enum ProductType: int
case SKU = 3;
case productOffer = 4;
case genericOffer = 5;
}
case skuMaster = 6;
case service = 7;
}
13 changes: 9 additions & 4 deletions src/Services/Catalog/Common/Result/AbstractCatalogItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ public function __construct(array $data, ?Currency $currency = null)
* @return bool|CarbonImmutable|int|mixed|null
*/

#[\Override]
public function __get($offset)
{
switch ($offset) {
case 'active':
case 'available':
case 'bundle':
case 'vatIncluded':
case 'withoutOrder':
case 'subscribe':
case 'quantityTrace':
return $this->data[$offset] === 'Y';
case 'barcodeMulti':
case 'canBuyZero':
case 'recurSchemeType':
if ($this->data[$offset] !== null) {
return $this->data[$offset] === 'Y';
}
Expand All @@ -67,8 +73,7 @@ public function __get($offset)
case 'id':
case 'modifiedBy':
case 'sort':
case 'height':
case 'length':
case 'vatId':
if ($this->data[$offset] !== '' && $this->data[$offset] !== null) {
return (int)$this->data[$offset];
}
Expand All @@ -78,7 +83,7 @@ public function __get($offset)
case 'dateActiveTo':
case 'dateCreate':
case 'timestampX':
if ($this->data[$offset] !== '') {
if ($this->data[$offset] !== '' && $this->data[$offset] !== null) {
return CarbonImmutable::createFromFormat(DATE_ATOM, $this->data[$offset]);
}

Expand Down Expand Up @@ -109,4 +114,4 @@ protected function getKeyWithUserfieldByFieldName(string $fieldName)

return $this->$fieldName;
}
}
}
68 changes: 68 additions & 0 deletions src/Services/Catalog/Product/Offer/Result/OfferItemResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Catalog\Product\Offer\Result;

use Bitrix24\SDK\Services\Catalog\Common\ProductType;
use Bitrix24\SDK\Services\Catalog\Common\Result\AbstractCatalogItem;
use Carbon\CarbonImmutable;

/**
* @property-read bool $active
* @property-read bool $available
* @property-read ?bool $barcodeMulti
* @property-read bool $bundle
* @property-read ?bool $canBuyZero
* @property-read string $code
* @property-read int $createdBy
* @property-read CarbonImmutable|null $dateActiveFrom
* @property-read CarbonImmutable|null $dateActiveTo
* @property-read CarbonImmutable $dateCreate
* @property-read array|null $detailPicture
* @property-read string $detailText
* @property-read string $detailTextType
* @property-read ?string $height
* @property-read int $id
* @property-read int $iblockId
* @property-read ?array $iblockSection
* @property-read ?int $iblockSectionId
* @property-read ?string $length
* @property-read ?int $measure
* @property-read int $modifiedBy
* @property-read string $name
* @property-read ?array $parentId
* @property-read array|null $previewPicture
* @property-read string $previewText
* @property-read string $previewTextType
* @property-read ?string $purchasingCurrency
* @property-read ?string $purchasingPrice
* @property-read ?string $quantity
* @property-read ?string $quantityReserved
* @property-read bool $quantityTrace
* @property-read ?int $recurSchemeLength
* @property-read ?bool $recurSchemeType
* @property-read int $sort
* @property-read bool $subscribe
* @property-read CarbonImmutable $timestampX
* @property-read ?int $trialPriceId
* @property-read ProductType $type
* @property-read ?int $vatId
* @property-read bool $vatIncluded
* @property-read ?string $weight
* @property-read ?string $width
* @property-read bool $withoutOrder
* @property-read string $xmlId
*/
class OfferItemResult extends AbstractCatalogItem
{
}
24 changes: 24 additions & 0 deletions src/Services/Catalog/Product/Offer/Result/OfferResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Catalog\Product\Offer\Result;

use Bitrix24\SDK\Core\Result\AbstractResult;

class OfferResult extends AbstractResult
{
public function offer(): OfferItemResult
{
return new OfferItemResult($this->getCoreResponse()->getResponseData()->getResult()['offer']);
}
}
Loading
Loading