Skip to content

Commit

Permalink
Merge pull request #1351 from bakaphp/development
Browse files Browse the repository at this point in the history
Hotfix Release - 1.32
  • Loading branch information
kaioken authored May 18, 2024
2 parents bea5e58 + 832c39d commit 7e3e869
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 30 deletions.
28 changes: 14 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion graphql/schemas/Inventory/product.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,19 @@ input ProductInput {
source_id: Mixed
variants: [VariantsInput!]
status: StatusReferenceInput
attributes: [AttributeInput!]
attributes: [ProductAttributesInput!]
files: [FilesystemInputUrl!]
price: Float
company_id: ID
custom_fields: [CustomFieldEntityInput!]
}

input ProductAttributesInput {
id: ID
name: String!
value: Mixed
}

input ProductInputUpdate {
products_types_id: Int
name: String
Expand All @@ -64,6 +70,7 @@ input ProductInputUpdate {
upc: String
is_published: Boolean
status: StatusReferenceInput
attributes: [ProductAttributesInput!]
files: [FilesystemInputUrl!]
}

Expand Down
1 change: 1 addition & 0 deletions graphql/schemas/Inventory/variant.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type VariantPricingInfo{
is_coming_soon: Boolean
}

#@deprecated(reason: "Use the ProductAttributesInput type instead")
input VariantsAttributesInput {
id: ID
name: String!
Expand Down
24 changes: 13 additions & 11 deletions src/Domains/Inventory/Products/Actions/CreateProductAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Kanvas\Companies\Repositories\CompaniesRepository;
use Kanvas\Connectors\Shopify\Enums\StatusEnum;
use Kanvas\Connectors\Shopify\Services\ShopifyInventoryService;
use Kanvas\Inventory\Attributes\Actions\CreateAttribute;
use Kanvas\Inventory\Attributes\DataTransferObject\Attributes as AttributesDto;
use Kanvas\Inventory\Attributes\Models\Attributes;
use Kanvas\Inventory\Categories\Repositories\CategoriesRepository;
use Kanvas\Inventory\Products\DataTransferObject\Product as ProductDto;
use Kanvas\Inventory\Products\Models\Products;
Expand Down Expand Up @@ -82,15 +81,18 @@ public function execute(): Products

if ($this->productDto->attributes) {
foreach ($this->productDto->attributes as $attribute) {
$attributesDto = AttributesDto::from([
'app' => $this->productDto->app,
'user' => $this->user,
'company' => $this->productDto->company,
'name' => $attribute['name'],
'value' => $attribute['value'],
]);

$attributeModel = (new CreateAttribute($attributesDto, $this->user))->execute();
if (isset($attribute['id'])) {
$attributeModel = Attributes::getById((int) $attribute['id'], $products->app);
} else {
$attributesDto = AttributesDto::from([
'app' => $this->productDto->app,
'user' => $this->user,
'company' => $this->productDto->company,
'name' => $attribute['name'],
]);

$attributeModel = (new CreateAttribute($attributesDto, $this->user))->execute();
}
(new AddAttributeAction($products, $attributeModel, $attribute['value']))->execute();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Domains/Inventory/Variants/Models/Variants.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function addAttributes(UserInterface $user, array $attributes): void
}

if (isset($attribute['id'])) {
$attributeModel = Attributes::getById((int) $attribute['id']);
$attributeModel = Attributes::getById((int) $attribute['id'], $this->app);
} else {
$attributesDto = AttributesDto::from([
'app' => app(Apps::class),
Expand Down
2 changes: 1 addition & 1 deletion src/Kanvas/Enums/AppEnums.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getValue(): mixed
self::KANVAS_APP_REGION_HEADER => 'X-Kanvas-Region',
self::KANVAS_APP_COMPANY_AUTH_HEADER => 'Company-Authorization', //@deprecated
self::DISPLAYNAME_LOGIN => 'displayname_login',
self::VERSION => '1.0-BETA-30',
self::VERSION => '1.0-BETA-32',
self::ANONYMOUS_USER_ID => -1
};
}
Expand Down
30 changes: 28 additions & 2 deletions tests/GraphQL/Inventory/ProductsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ public function testSave(): void
'name' => fake()->name,
'description' => fake()->text,
'sku' => fake()->time,
'attributes' => [
[
'name' => fake()->name,
'value' => fake()->name,
],
],
];

$response = $this->graphQL('
Expand All @@ -25,6 +31,10 @@ public function testSave(): void
{
name
description
attributes {
name
value
}
}
}', ['data' => $data]);

Expand Down Expand Up @@ -218,13 +228,23 @@ public function testAddVariantToProduct(): void
'name' => fake()->name,
'description' => fake()->text,
'sku' => fake()->time,
'attributes' => [
[
'name' => fake()->name,
'value' => fake()->name,
],
],
];
$response = $this->graphQL('
mutation($data: ProductInput!) {
createProduct(input: $data)
{
name
description
attributes {
name
value
}
}
}', ['data' => $data]);

Expand Down Expand Up @@ -258,7 +278,13 @@ public function testAddVariantToProduct(): void
'description' => fake()->text,
'products_id' => $id,
'sku' => fake()->time,
'warehouse' => $warehouseData
'warehouse' => $warehouseData,
'attributes' => [
[
'name' => fake()->name,
'value' => fake()->name,
],
],
];
$variantResponse = $this->graphQL('
mutation($data: VariantsInput!) {
Expand Down Expand Up @@ -371,7 +397,7 @@ public function testDeleteVariantToProduct(): void
'description' => fake()->text,
'products_id' => $id,
'sku' => fake()->time,
'warehouse' => $warehouseData
'warehouse' => $warehouseData,
];
$variantResponse = $this->graphQL('
mutation($data: VariantsInput!) {
Expand Down

0 comments on commit 7e3e869

Please sign in to comment.