from django.contrib import admin
from .models import Product, Variation

class VariationInline(admin.TabularInline):
    model = Variation
    extra = 0

@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
    list_display = ('name', 'sku', 'price', 'stock_status', 'total_sales')
    search_fields = ('name', 'sku', 'wp_id')
    list_filter = ('stock_status',)
    inlines = [VariationInline]

@admin.register(Variation)
class VariationAdmin(admin.ModelAdmin):
    list_display = ('product', 'size', 'price', 'stock_quantity')
    search_fields = ('product__name', 'size')