Skip to content

Commit

Permalink
Version 2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhirtz committed Mar 28, 2024
1 parent 9f0bcec commit 6e737d2
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.1.2 (Mar 28, 2024)

- Fixed `inventory_quantity` allowing `null` values (Issue #3)
- Fixed API error handling (Issue #2)

## 2.1.1 (Jan 29, 2024)

- Minor improvements
Expand Down
5 changes: 3 additions & 2 deletions src/components/rest/ShopifyAdminRestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ protected function requestInternal(string $method, string $uri, array $options =
// consulting the error log ...
if ($exception instanceof ClientException) {
$contents = Json::decode($exception->getResponse()->getBody()->getContents());
$this->_errors = $contents['errors'] ?? [$exception->getMessage() ?: 'Unknown API Error'];
$errors = $contents['errors'] ?? $exception->getMessage() ?: 'Unknown API Error';
$this->_errors = (array)$errors;
}

Yii::error($exception);
Expand All @@ -148,7 +149,7 @@ private function getNextLinkFromHeader(array $headers): ?string
$links = $headers['Link'][0] ?? null;

if ($links) {
$links = explode(',', (string) $links);
$links = explode(',', (string)$links);

foreach ($links as $link) {
if (preg_match('/<(.*)>;\srel=\"next\"/', $link, $matches)) {
Expand Down
2 changes: 1 addition & 1 deletion src/migrations/M190904193339Shopify.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function safeUp(): void
'option_3' => $this->string()->null(),
'barcode' => $this->string()->null(),
'sku' => $this->string()->null(),
'is_taxable' => $this->boolean()->defaultValue(false),
'is_taxable' => $this->boolean()->defaultValue(false)->notNull(),
'grams' => $this->decimal(10, 2)->unsigned()->null(),
'weight' => $this->string()->null(),
'weight_unit' => $this->string(2)->null(),
Expand Down
27 changes: 27 additions & 0 deletions src/migrations/M240328135307ProductVariant.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace davidhirtz\yii2\shopify\migrations;

use davidhirtz\yii2\shopify\models\ProductVariant;
use davidhirtz\yii2\skeleton\db\traits\MigrationTrait;
use yii\db\Migration;

/**
* @noinspection PhpUnused
*/

class M240328135307ProductVariant extends Migration
{
use MigrationTrait;

public function safeUp(): void
{
$this->alterColumn(ProductVariant::tableName(), 'inventory_quantity', $this->integer()
->unsigned()
->null());
}

public function safeDown(): void
{
}
}
4 changes: 2 additions & 2 deletions src/models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* @property int $id
* @property int $status
* @property int $variant_id
* @property int|null $variant_id
* @property int|null $image_id
* @property string $name
* @property string|null $content
Expand All @@ -38,7 +38,7 @@
*
* @property-read ProductImage|null $image {@see static::getImage()}
* @property-read ProductImage[] $images {@see static::getImages()}
* @property-read ProductVariant $variant {@see static::getVariant()}
* @property-read ProductVariant|null $variant {@see static::getVariant()}
* @property-read ProductVariant[] $variants {@see static::getVariants()}
*/
class Product extends ActiveRecord implements DraftStatusAttributeInterface
Expand Down
10 changes: 5 additions & 5 deletions src/models/ProductImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* @property int $id
* @property int $product_id
* @property int $position
* @property string $alt_text
* @property int $width
* @property int $height
* @property string $src
* @property DateTime $updated_at
* @property string|null $alt_text
* @property int|null $width
* @property int|null $height
* @property string|null $src
* @property DateTime|null $updated_at
* @property DateTime $created_at
*/
class ProductImage extends ActiveRecord
Expand Down
30 changes: 14 additions & 16 deletions src/models/ProductVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
* @property string $name
* @property int $position
* @property int $price
* @property int $compare_at_price
* @property string $presentment_prices
* @property string $option_1
* @property string $option_2
* @property string $option_3
* @property string $barcode
* @property string $sku
* @property int|null $compare_at_price
* @property string|null $presentment_prices
* @property string|null $option_1
* @property string|null $option_2
* @property string|null $option_3
* @property string|null $barcode
* @property string|null $sku
* @property bool $is_taxable
* @property int $grams
* @property int $weight
* @property string $weight_unit
* @property bool $inventory_management
* @property int $inventory_quantity
* @property string $inventory_policy
* @property DateTime $updated_at
* @property int|null $grams
* @property int|null $weight
* @property string|null $weight_unit
* @property string|null $inventory_management
* @property int|null $inventory_quantity
* @property string|null $inventory_policy
* @property DateTime|null $updated_at
* @property DateTime $created_at
*/
class ProductVariant extends ActiveRecord
Expand All @@ -41,7 +41,6 @@ class ProductVariant extends ActiveRecord
use ModuleTrait;
use ProductRelationTrait;


public function behaviors(): array
{
return [
Expand All @@ -51,7 +50,6 @@ public function behaviors(): array
];
}


public function rules(): array
{
return $this->getI18nRules([
Expand Down

0 comments on commit 6e737d2

Please sign in to comment.