Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown column sku in field list #2016

Open
dualklip opened this issue Nov 12, 2024 · 1 comment
Open

Unknown column sku in field list #2016

dualklip opened this issue Nov 12, 2024 · 1 comment
Labels
bug Something isn't working unconfirmed

Comments

@dualklip
Copy link
Contributor

  • Lunar version: 1.x

In the Full Example of how to create a product (https://docs.lunarphp.io/core/reference/products.html#full-example) there is a reference to a field which should no longer be there because it causes an error. Is the sku field:

Lunar\Models\Product::create([
    'product_type_id' => $productType->id,
    'status' => 'published',
    'brand_id' => $brandId,
    'sku' => 'DRBOOT',
    'attribute_data' => [
        'name' => new TranslatedText(collect([
            'en' => new Text('1460 PATENT LEATHER BOOTS'),
        ])),
        'description' => new Text('Even more shades from our archive...'),
    ],
]);
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sku' in 'field list' ...

I can make a MR with the change but first I need confirmation of this iisue and second I'm not pretty sure if a have to do the MR to the v1-docs branch or 1.x.

The documentation say this:

For documentation of new features in an upcoming release, target the main branch.
https://docs.lunarphp.io/core/contributing.html#documentation-updates

@dualklip dualklip added bug Something isn't working unconfirmed labels Nov 12, 2024
@Beaudinn
Copy link

@dualklip the sku field is no longer part of the Product model, which is causing the error you encountered. Instead, the sku field should be added to a product variant, as shown below:

$variant = $product->variants()->create([
    'tax_class_id' => TaxClass::getDefault()->id,
    'sku' => $data['sku'],
]);

the sku belongs to the variant rather than the product itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed
Projects
None yet
Development

No branches or pull requests

2 participants