Skip to main content

Model

The model used is Shopper\Core\Models\ProductVariant.
NameTypeRequiredNotes
idautoincauto
namestringyesThe name of the product variant.
skustringnoNullable, Unique, the Stock Keeping Unit (SKU) code of the product variant
barcodestringnoNullable, Unique, the barcode of the product variant.
eanstringnoNullable, Unique, the european article numbering
upcstringnoNullable, Unique, the code universel des produits
allow_backorderbooleanyesDefault false
positionintyesDefault 1
product_idintyesInt (Product object via the product relation)
weight_unitstringyesThe weight unit of the product Shopper\Core\Enum\Dimension\Weight, default kg
weight_valuefloatnoThe weight value of the product, default 0.00
height_unitstringyesThe height unit of the product Shopper\Core\Enum\Dimension\Length, default cm
height_valuefloatnoThe height value of the product, default 0.00
width_unitstringyesThe width unit of the product Shopper\Core\Enum\Dimension\Length, default cm
width_valuefloatnoThe width value of the product, default 0.00
depth_unitstringyesThe depth unit of the product Shopper\Core\Enum\Dimension\Length, default cm
depth_valuefloatnoThe depth value of the product, default 0.00
volume_unitstringyesThe volume unit of the product Shopper\Core\Enum\Dimension\Volume, default l
volume_valuefloatnoThe volume value of the product, default 0.00
metadataarraynoNullable,
Models are customizable, and we recommend changing the ProductVariant model when you configure your site. To change the model you need to look at the configuration file config/shopper/models.php.
use Shopper\Core\Models;

return [
    // ...
    'variant' => Models\ProductVariant::class, // [tl! ++]
];
  1. Create your own Model
    php artisan make:model ProductVariant
    
    Once the app/Models/ProductVariant.php model is created in your app folder, you need to extend from the Shopper\Core\Models\ProductVariant Model.
  2. Extend your ProductVariant model from the ProductVariant Shopper Model
    namespace App\Models;
    
    use Shopper\Core\Models\ProductVariant as Model;
    
    class ProductVariant extends Model
    {
    }
    
  3. Use variant key for the model on the models.php config file to use our new model
    'variant' => \App\Models\ProductVariant::class, // [tl! ++]
    

Components

By default, product variant Livewire components are not published. To customize components, you must publish them.
php artisan shopper:component:publish product
This command will publish all Livewire components used for product management (from pages to form components). Once you’ve published the component, you can find it in the product.php locate in the config/shopper/components folder.
use Shopper\Livewire;

return [

    /*
    |--------------------------------------------------------------------------
    | Livewire Pages
    |--------------------------------------------------------------------------
    */

    'pages' => [
        'product-index' => Livewire\Pages\Product\Index::class,
        'product-edit' => Livewire\Pages\Product\Edit::class,
        'variant-edit' => Livewire\Pages\Product\Variant::class,
        'attribute-index' => Livewire\Pages\Attribute\Browse::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Livewire Components
    |--------------------------------------------------------------------------
    */

    'components' => [
        'products.form.attributes' => Components\Products\Form\Attributes::class,
        'products.form.edit' => Components\Products\Form\Edit::class,
        'products.form.media' => Components\Products\Form\Media::class,
        'products.form.files' => Components\Products\Form\Files::class,
        'products.form.inventory' => Components\Products\Form\Inventory::class,
        'products.form.related-products' => Components\Products\Form\RelatedProducts::class,
        'products.form.seo' => Components\Products\Form\Seo::class,
        'products.form.shipping' => Components\Products\Form\Shipping::class,
        'products.form.variants' => Components\Products\Form\Variants::class,
        'products.variant-stock' => Components\Products\VariantStock::class,
        'products.type-configuration' => Components\Products\ProductTypeConfiguration::class,
        'products.pricing' => Components\Products\Pricing::class,

        'modals.related-products-list' => Livewire\Modals\RelatedProductsList::class,

        'slide-overs.add-product' => Livewire\SlideOvers\AddProduct::class,
        'slide-overs.add-variant' => Livewire\SlideOvers\AddVariant::class,
        'slide-overs.update-variant' => Livewire\SlideOvers\UpdateVariant::class,
        'slide-overs.generate-variants' => Livewire\SlideOvers\GenerateVariants::class,
        'slide-overs.attribute-form' => Livewire\SlideOvers\AttributeForm::class,
        'slide-overs.choose-product-attributes' => Livewire\SlideOvers\ChooseProductAttributes::class,
        'slide-overs.attribute-values' => Livewire\SlideOvers\AttributeValues::class,
        'slide-overs.manage-pricing' => Livewire\SlideOvers\ManagePricing::class,
    ],

];