zakharov-andrew / yii2-shop
Yii2 Shop
Installs: 61
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 0
Open Issues: 0
Type:yii2-extension
pkg:composer/zakharov-andrew/yii2-shop
Requires
- php: >=7.3
- zakharov-andrew/yii2-image-upload-widget: *
This package is auto-updated.
Last update: 2025-10-29 20:40:14 UTC
README
Yii2 shop module. A module for creating an online store based on Yii2. This module provides basic functionality for managing products, categories, orders, and other elements of an e-commerce store.
Features β’ Installation β’ Usage β’ Contributing β’ License
π·πΊ Π ΡΡΡΠΊΠ°Ρ Π²Π΅ΡΡΠΈΡ
β¨ Features
- 
π¦ Product Management - Create, edit, and delete products.
- Add attributes and specifications to products.
- Upload product images.
- Manage product stock levels.
- Multi-store support
 
- 
ποΈ Categories and Filters - Hierarchical category system.
- Support for subcategories.
- Filter products by attributes (color, size, price, etc.).
- Flexible filter configuration for categories.
 
- 
π Order Management - Create and manage orders.
- Order statuses (new, processing, delivered, canceled, etc.).
- Order history and change tracking.
- Support for various delivery methods.
 
- 
π Shopping Cart and Checkout - Add products to the cart.
- Edit the cart (change quantities, remove products).
- Checkout with customer details.
- Coupon and discount support (planned for future updates).
 
- 
π€ User and Role Management - User registration and authentication.
- Role and permission management (admin, manager, customer).
- User account with order history.
 
- 
π Search and SEO - Search products by name, description, and attributes.
- SEO optimization: meta tags, human-readable URLs (slug).
- Sitemap generation (sitemap.xml).
 
- 
π Multilingual Support - Support for multiple languages in the store interface.
 
- 
π Analytics and Reports - Sales reports.
- Product popularity analysis.
- Export data to CSV, Excel, and other formats.
 
- 
βοΈ Store Settings - Flexible configuration of core store parameters.
- Email notification settings for customers and administrators.
 
π Installation
The preferred way to install this extension is through composer.
Either run
$ composer require zakharov-andrew/yii2-shop
or add
"zakharov-andrew/yii2-shop": "*"
to the require section of your composer.json file.
Subsequently, run
./yii migrate/up --migrationPath=@vendor/zakharov-andrew/yii2-shop/migrations
in order to create the settings table in your database.
Or add to console config
return [ // ... 'controllerMap' => [ // ... 'migrate' => [ 'class' => 'yii\console\controllers\MigrateController', 'migrationPath' => [ '@console/migrations', // Default migration folder '@vendor/zakharov-andrew/yii2-shop/src/migrations' ] ] // ... ] // ... ];
π Usage
Add this to your main configuration's modules array
'modules' => [ 'shop' => [ 'class' => 'ZakharovAndrew\shop\Module', 'catalogTitle' => 'Catalog Title', 'storeName' => 'My Store', 'bootstrapVersion' => 5, // if use bootstrap 5 'deliveryMethods' => [ 1 => 'Courier delivery', 2 => 'Pickup from store', 3 => 'Postal delivery' ], 'defaultProductImage' => '/images/default-product-image.jpg', // Path to the default image for a product 'uploadWebDir' => '/web/path/to/upload/dir/' ], 'imageupload' => [ 'class' => 'ZakharovAndrew\imageupload\Module', 'uploadDir' => '/path/to/upload/dir/', ], // ... ],
Note: the maximum number of additional parameters is 3. Change the value of uploadDir to the directory for uploading images. Uses the yii2-image-upload-widget module to upload images.
Add this to your main configuration's urlManager array
'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ // ... 'catalog/<url:[\w\-]+>' => 'shop/product-category/view', 'catalog' => 'shop/catalog/index', 'product/<url:[\w\d\-]+>' => 'shop/product/view', 'tag/<url:[\w\d\-]+>' => 'product-tag/view', 'cart' => 'shop/cart/index', 'checkout' => 'shop/checkout/index', 'admin/orders' => 'shop/admin-order/index', 'admin/orders/<id:\d+>' => 'shop/admin-order/view', 'admin/orders/update-status/<id:\d+>' => 'shop/admin-order/update-status', // ... ], ],
Register the component in config/web.php:
'components' => [ 'shopSettings' => [ 'class' => 'ZakharovAndrew\shop\components\ShopSettings', ], // ... ],
π― Product Swiper Widget
The ProductSwiperWidget allows you to create beautiful product sliders with swiper functionality.
Basic Usage
<?= \ZakharovAndrew\shop\widgets\ProductSwiperWidget::widget([ 'title' => 'New Arrivals', 'categoryId' => 4, ]) ?>
Display Specific Products by IDs
<?= \ZakharovAndrew\shop\widgets\ProductSwiperWidget::widget([ 'title' => 'Featured Products', 'productIds' => [1, 5, 8, 12, 15, 20], 'id' => 'featured-products', 'swiperId' => 'swiper-featured', ]) ?>
Advanced Configuration
<?= \ZakharovAndrew\shop\widgets\ProductSwiperWidget::widget([ 'title' => 'Best Sellers', 'categoryId' => 4, 'productIds' => [], // Optional: specify exact product IDs 'limit' => 10, 'orderBy' => 'sales_count DESC', 'id' => 'bestsellers-slider', 'swiperId' => 'swiper-bestsellers', 'viewFile' => '@app/views/custom/_product', // Custom product view ]) ?>
Widget Parameters
| Parameter | Type | Default | Description | 
|---|---|---|---|
| title | string | 'New Arrivals' | Slider title | 
| productIds | array | [] | Specific product IDs to display | 
| categoryId | integer | null | Category ID to load products from | 
| limit | integer | 14 | Number of products to show | 
| orderBy | string | 'created_at DESC' | Products sorting order | 
| id | string | 'product-swiper' | Main container ID | 
| swiperId | string | 'swiper-products' | Swiper container ID | 
| viewFile | string | '@vendor/.../_product' | Product view template | 
Features
- Automatic Swiper Initialization: Swiper library is automatically loaded and initialized
- Single Library Load: Swiper assets are loaded only once even with multiple widgets
- Flexible Product Selection: Choose products by IDs or category
- Customizable Styling: Easy to customize with CSS classes
- Responsive Design: Built-in responsive breakpoints
- Accessibility: Proper ARIA labels and keyboard navigation
π₯ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -m 'Add some amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.