Skip to content

Automatic SKU generation issue #78

@samuelabate

Description

@samuelabate

Hello there,

I was using this great library but I encountered an issue. I am on Laravel 5.7 and even though I have created the inventory with category_id and metric_id provided, the sku is not generated. The functions $inventory->generateSku(), $inventory->regenerateSku() and $inventory->hasSku() all return an empty string even though $inventory->createSKU("skuCode"); works fine. If you need to know, Here is the code i've used:

        try {

            $inventory = new Inventory();

            $inventory->name = $request->inventoryName;
            $inventory->category_id = $request->categoryId;
            $inventory->metric_id = $request->metricId;
            $inventory->description = $request->inventoryDescription;

            $inventory->save();

            $inventory->category;
            $inventory->metric;
            $inventory->sku;

            $response['success'] = true;
            $response['inventory'] = $inventory;
            $response['message'] = "Inventory Created Successfully.";
        } catch (\Exception $e) {
            $response['success'] = false;
            $response['message'] = $e->getMessage();
        }

Can you please suggest what I should do to resolve the issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions