Skip to main content

Overview

The inventory management system in Yoneily is built around product galleries that support images, pricing, stock levels, and categorization. Each product is represented as a gallery item with comprehensive tracking capabilities.
FieldTypeDescription
id_galeriaintUnique product identifier
texto_galeriavarchar(255)Product name/title
descripciontextDetailed product description
thumbnailstextMain product image filename
urlvarchar(255)SEO-friendly URL slug
clavesvarchar(255)Keywords/tags for search
publicarintPublication status (0=hidden, 1=published)
preciodoubleProduct price
garantiavarchar(255)Warranty information
cantidadintTotal quantity received
cantidad_existenteintCurrent stock level
cantidad_alertaintLow stock alert threshold
prod_vendidosintTotal units sold
locale_id_localintStore/vendor association
usuario_id_usuariointUser who created the product
fechacre_galeriatimestampCreation date
excluirtinyintExclude from listings

Product Management Workflows

Adding Products

1

Navigate to Product Management

Access Galleries > Add from the admin panel
2

Enter Product Details

Fill in the required information:
  • Product Name (texto_galeria) - required
  • Description - required
  • Keywords (claves) - required for SEO
  • Price - product cost
  • Warranty - warranty terms
3

Upload Product Image

Select a product image (thumbnails field):Supported formats: JPG, JPEG, PNG, GIFProcessing:
  • Original stored in /files/galeria/otras/
  • Thumbnail (124x124) generated in /files/galeria/thumbnails/
  • Display version (600x480) in /files/galeria/normal/
4

Set Stock Levels

Define inventory quantities:
  • Initial Quantity (cantidad) - total received
  • Alert Threshold (cantidad_alerta) - low stock warning
  • System automatically sets cantidad_existente = cantidad
  • System initializes prod_vendidos = 0
5

Assign to Store

Select the associated store/vendor (auto-filled for vendor users)
6

Attach Additional Images (Optional)

Add multiple product images through the file attachment system

Image Processing

Yoneily automatically generates multiple image sizes for optimal display:
$image = new SimpleImage();
$image->load($original_file_path);
if($image->getWidth() > 124){
    $image->resizeToWidth(124);
}
if($image->getHeight() > 124){
    $image->resizeToHeight(124);
}
$image->save($thumbnail_path);

URL Generation

Products automatically generate SEO-friendly URLs: Formula: texto_galeria + claves (slugified and deduplicated) Example:
  • Product Name: “Mesa de Madera”
  • Keywords: “artesanal roble”
  • Generated URL: mesa-de-madera-artesanal-roble
  • If duplicate: mesa-de-madera-artesanal-roble_1
URLs are automatically generated in the beforeSave() model method, ensuring uniqueness across the system.

Stock Management

Stock Tracking Fields

Total Quantity ReceivedThe original inventory count when the product was added or restocked.

Stock Updates on Sale

When a product is sold, the system automatically:
  1. Validates stock availability (cantidad_existente > 0)
  2. Decrements inventory:
    $cantidad_existente = $cantidad_existente - $cantidad_vendida
    
  3. Increments sold counter:
    $prod_vendidos = $prod_vendidos + $cantidad_vendida
    
  4. Updates database via Gallery->updateAll()
Products with cantidad_existente = 0 are automatically prevented from being purchased.

Product Editing

Edit Workflow

  1. Navigate to Galleries > Index
  2. Select product to edit
  3. Modify fields:
    • Product information
    • Description and keywords
    • Price and warranty
    • Stock quantities (resets cantidad_existente to new cantidad)
  4. Upload new image (optional)
    • New image replaces old thumbnail/normal versions
    • Original is preserved in /otras/ directory
  5. Save changes

Product Visibility

Publication Status

Control product visibility with the publicar field:

Activate Product

Route: /galleries/activa/{id}Sets publicar = 1 to make product visible to customers

Deactivate Product

Route: /galleries/desactiva/{id}Sets publicar = 0 to hide product from public view
Use Cases for Deactivation:
  • Out of stock items (temporarily)
  • Seasonal products
  • Products under review
  • Testing new listings

Categories

Category Structure

Products can be organized using hierarchical categories:
FieldDescription
id_categoriasCategory ID
nombre_categoriasCategory name
categorias_id_categoriasParent category (for subcategories)
usuario_id_usuarioUser who created category

Category Relationships

Categories use a hasAndBelongsToMany (HABTM) relationship with products:
  • Join table: categories_galleries
  • Products can belong to multiple categories
  • Categories can contain multiple products

Multiple Images

File Attachments

Products support multiple images through the file attachment system: Join Table: archivos_galleries Fields:
  • files_id_file - Reference to file in archivos table
  • galerias_id_galeria - Reference to product
Supported Media Types:
  • Images: JPG, JPEG, PNG, GIF
  • Audio: MP3
  • Flash: SWF, FLV

Deleting Images

Image deletion is permanent and uses a direct SQL query to remove records from both archivos and archivos_galleries tables.
Delete Route: /galleries/deleteimg/{gallery_id}/{file_id}

Store/Vendor Filtering

Vendor View

When vendors log in, they see only their own products:
$user = $this->Session->read('Auth.User.locale_id_local');
if(!empty($user)){
    $conditions = array('Gallery.locale_id_local' => $user);
}
Benefits:
  • Data isolation between vendors
  • Simplified inventory view
  • Faster query performance

Administrator View

Administrators see products from all stores with no filtering applied.

Product Listing

Pagination

Products are displayed with pagination: Settings:
  • 10 products per page
  • Ordered by fechacre_galeria DESC (newest first)
  • Includes related data:
    • User information
    • Store/locale details
    • Categories
    • Attached files

Store Lookup (AJAX)

The system provides an autocomplete store search: Endpoint: /galleries/verlocal Parameters: term (search query) Returns: JSON array of matching stores
[
  {
    "id": 1,
    "value": "El Punto Artesanal de Magdaleno"
  }
]

Product Deletion

Delete Workflow

1

Select Product

Navigate to product listing and choose product to delete
2

Confirm Deletion

Click delete button (usually shows confirmation)
3

Cascade Delete

System removes:
  • Product record from galleries table
  • Associated category links
  • File attachments (metadata, not physical files)
4

Redirect

Return to product listing with success message

Search & Filtering

Product Discovery

Products can be found through:
  1. Category Browse - Navigate category hierarchy
  2. Keyword Search - Search using claves field
  3. Store Filter - View products by vendor
  4. URL Direct Access - SEO-friendly URLs

Keywords (claves)

Keywords improve product discoverability: Best Practices:
  • Use descriptive terms
  • Include material types
  • Add color variations
  • Specify product categories
  • Include brand names (if applicable)
Example:
Product: Handcrafted Wooden Chair
Keywords: madera artesanal silla roble comedor

Sales Tracking

View product sales and revenue

Galleries

Manage multimedia content

User Management

Vendor access control

Technical Details

Model Relationships

Gallery Model Associations:

beLongsTo:
  - User (creator)
  - Locale (store)

hasAndBelongsToMany:
  - Archivo (files)
  - Category (categories)

hasMany:
  - Newsgalleries (news associations)

Image Upload Behavior

The Gallery model uses MeioUpload behavior:
'MeioUpload' => array(
    'thumbnails' => array(
        'dir' => 'files{DS}galeria/otras',
        'create_directory' => true,
        'thumbnailQuality' => 50,
        'useImageMagick' => true,
        'allowed_mime' => ['image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'],
        'allowed_ext' => ['.jpg', '.jpeg', '.png', '.gif']
    )
)

Validation Rules

  • Required field (notEmpty)
  • Used in URL generation
  • No maximum length enforced
  • Required field (notEmpty)
  • Text field for detailed information
  • Required field (notEmpty)
  • Used in URL generation and search
  • Required field (notEmpty)
  • Must reference existing locale

Build docs developers (and LLMs) love