This repository has been archived by the owner on Apr 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.1.0: Added new cache generators, changed cache iterator.
- Loading branch information
1 parent
8a060ce
commit dc31a6b
Showing
36 changed files
with
1,913 additions
and
1,692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
# Shopahelper plugin for Shopaholic | ||
|
||
Shopahelper is a basic bulk tool that helps you to manage your catalog. | ||
|
||
### Caching: | ||
- `shopahelper:cache.all {chunk}` - Cache all Products, Brands, Categories, Offers by chunks with N items. | ||
- `shopahelper:cache.products {chunk}` - Cache Products by chunks with N products. | ||
- `shopahelper:cache.brands {chunk}` - Cache Brands by chunks with N brands. | ||
- `shopahelper:cache.categories {chunk}` - Cache Categories by chunks with N categories. | ||
- `shopahelper:cache.offers {chunk}` - Cache Offers by chunks with N offers. | ||
|
||
### Generators | ||
- `shopahelper:generate.offers` - Generating offers for each product that doesn't have it. | ||
|
||
### Linkers | ||
|
||
- `{products}` - In that variable you can pass a single ID or Multiple ID's separated by commas. Example: `shopahelper:link.brand-to-products 1 13,14,15` - Link Brand with id 1 to Products with id 13,14 and 15. | ||
|
||
|
||
- Brands | ||
- `shopahelper:link.brand-to-products {brand_id} {products}` - Link Brand by id to products by id's separated by comma. | ||
- `shopahelper:link.brand-to-products-by-category {brand_id} {category_id}` - Link Brand by ID to products inside Category by ID | ||
- Category | ||
- `shopahelper:link.category-to-products {category_id} {products}` - Link Category by ID to Products by ID's separated by comma | ||
- `shopahelper:link.category-to-products-by-category {old_category_id} {new_category_id}` - Link main Category ID to Products by their main Category ID; | ||
- Additional Category | ||
- `shopahelper:link.add-categories-to-products {category_id} {products}` - Link Additional Category by ID to Products by ID's separated by comma | ||
- `shopahelper:link.add-category-to-products-by-add-category {target_category_id} {current_category_id}` - Link Additional Category by ID to Products that has additional category by ID | ||
- `shopahelper:link.add-category-to-products-by-category {target_category_id} {current_category_id}` - Link Additional Category by ID to Products that has main Category by ID | ||
|
||
### Detachers | ||
|
||
- `{products}` - In that variable you can pass a single ID or Multiple ID's separated by commas. | ||
|
||
- `shopahelper:detach.add-category-from-products {category} {products}` - Detaches Additional Category from Products by ID's separated by comma | ||
|
||
### Prices | ||
|
||
- `{products}` - In that variable you can pass a single ID or Multiple ID's separated by commas. Example: `shopahelper:price.upscale-by-percentage 10 13,14,15` - Upscale offers price by 10% in Products with id's 13,14,15 | ||
- `{category_tree}` - Boolean variable that accepts `true` or `false` strings. If passed `true` - proceeds action to all subcategories of target category. | ||
|
||
|
||
- Upscale | ||
- `shopahelper:price.upscale-by-percentage {percentage} {products}` - Upscale price by N percentage to Offers of Products by ID's separated by comma | ||
- `shopahelper:price.upscale-by-percentage-by-brand {percentage} {brand_id}` - Upscale price by N percentage to Offers of Products of Brand by ID | ||
- `shopahelper:price.upscale-by-percentage-by-category {percentage} {category_id} {category_tree}` - Upscale price by N percentage to Offers of Products of Category by ID. | ||
- `shopahelper:price.upscale-by-percentage-custom` - Upscale price by N percentage to Offers of Products by ID's separated by comma with custom condition that you can specify in code. | ||
- Downscale | ||
- `shopahelper:price.downscale-by-percentage` - Downscale price by N percentage to Offers of Products by ID's separated by comma. | ||
- `shopahelper:price.downscale-by-percentage-by-brand` - Downscale price by N percentage to Offers of Products of Brand by ID | ||
- `shopahelper:price.downscale-by-percentage-by-category` - Downscale price by N percentage to Offers of Products of Category by ID. | ||
# Shopahelper plugin for Shopaholic | ||
|
||
Shopahelper is a basic bulk tool that helps you to manage your catalog. | ||
|
||
### Caching: | ||
- `shopahelper:cache.all {chunk}` - Cache all Products, Brands, Categories, Offers by chunks with N items. | ||
- `shopahelper:cache.products {chunk}` - Cache Products by chunks with N products. | ||
- `shopahelper:cache.brands {chunk}` - Cache Brands by chunks with N brands. | ||
- `shopahelper:cache.categories {chunk}` - Cache Categories by chunks with N categories. | ||
- `shopahelper:cache.offers {chunk}` - Cache Offers by chunks with N offers. | ||
|
||
### Generators | ||
- `shopahelper:generate.offers` - Generating offers for each product that doesn't have it. | ||
|
||
### Linkers | ||
|
||
- `{products}` - In that variable you can pass a single ID or Multiple ID's separated by commas. Example: `shopahelper:link.brand-to-products 1 13,14,15` - Link Brand with id 1 to Products with id 13,14 and 15. | ||
|
||
|
||
- Brands | ||
- `shopahelper:link.brand-to-products {brand_id} {products}` - Link Brand by id to products by id's separated by comma. | ||
- `shopahelper:link.brand-to-products-by-category {brand_id} {category_id}` - Link Brand by ID to products inside Category by ID | ||
- Category | ||
- `shopahelper:link.category-to-products {category_id} {products}` - Link Category by ID to Products by ID's separated by comma | ||
- `shopahelper:link.category-to-products-by-category {old_category_id} {new_category_id}` - Link main Category ID to Products by their main Category ID; | ||
- Additional Category | ||
- `shopahelper:link.add-categories-to-products {category_id} {products}` - Link Additional Category by ID to Products by ID's separated by comma | ||
- `shopahelper:link.add-category-to-products-by-add-category {target_category_id} {current_category_id}` - Link Additional Category by ID to Products that has additional category by ID | ||
- `shopahelper:link.add-category-to-products-by-category {target_category_id} {current_category_id}` - Link Additional Category by ID to Products that has main Category by ID | ||
|
||
### Detachers | ||
|
||
- `{products}` - In that variable you can pass a single ID or Multiple ID's separated by commas. | ||
|
||
- `shopahelper:detach.add-category-from-products {category} {products}` - Detaches Additional Category from Products by ID's separated by comma | ||
|
||
### Prices | ||
|
||
- `{products}` - In that variable you can pass a single ID or Multiple ID's separated by commas. Example: `shopahelper:price.upscale-by-percentage 10 13,14,15` - Upscale offers price by 10% in Products with id's 13,14,15 | ||
- `{category_tree}` - Boolean variable that accepts `true` or `false` strings. If passed `true` - proceeds action to all subcategories of target category. | ||
|
||
|
||
- Upscale | ||
- `shopahelper:price.upscale-by-percentage {percentage} {products}` - Upscale price by N percentage to Offers of Products by ID's separated by comma | ||
- `shopahelper:price.upscale-by-percentage-by-brand {percentage} {brand_id}` - Upscale price by N percentage to Offers of Products of Brand by ID | ||
- `shopahelper:price.upscale-by-percentage-by-category {percentage} {category_id} {category_tree}` - Upscale price by N percentage to Offers of Products of Category by ID. | ||
- `shopahelper:price.upscale-by-percentage-custom` - Upscale price by N percentage to Offers of Products by ID's separated by comma with custom condition that you can specify in code. | ||
- Downscale | ||
- `shopahelper:price.downscale-by-percentage` - Downscale price by N percentage to Offers of Products by ID's separated by comma. | ||
- `shopahelper:price.downscale-by-percentage-by-brand` - Downscale price by N percentage to Offers of Products of Brand by ID | ||
- `shopahelper:price.downscale-by-percentage-by-category` - Downscale price by N percentage to Offers of Products of Category by ID. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"name": "bizmark/shopahelper-plugin", | ||
"type": "october-plugin", | ||
"description": "The almighty helper in bulk actions for Shopaholic", | ||
"require": { | ||
"composer/installers": "~1.0" | ||
} | ||
} | ||
{ | ||
"name": "bizmark/shopahelpershopaholic-plugin", | ||
"type": "october-plugin", | ||
"description": "The almighty helper in bulk actions for Shopaholic", | ||
"require": { | ||
"composer/installers": "~1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,41 @@ | ||
<?php namespace BizMark\Shopahelper\Console\Cache; | ||
|
||
use Lovata\Shopaholic\Models\Brand; | ||
use Lovata\Shopaholic\Models\Category; | ||
use Lovata\Shopaholic\Models\Offer; | ||
use Lovata\Shopaholic\Models\Product; | ||
|
||
use Lovata\Shopaholic\Classes\Item\BrandItem; | ||
use Lovata\Shopaholic\Classes\Item\CategoryItem; | ||
use Lovata\Shopaholic\Classes\Item\OfferItem; | ||
use Lovata\Shopaholic\Classes\Item\ProductItem; | ||
|
||
trait CacheHelper | ||
{ | ||
/** | ||
* Processing cache of given model and ElementItem | ||
* | ||
* @param string $sName | ||
* @param string $obModel | ||
* @param string $obModelItem | ||
* @param string|Product|Category|Brand|Offer $obModel | ||
* @param string|ProductItem|CategoryItem|BrandItem|OfferItem $obModelItem | ||
*/ | ||
function generateCache($sName, $obModel, $obModelItem) | ||
{ | ||
$this->output->writeln('Generating ' . $sName . ' cache.'); | ||
$this->info('Generating '.$sName.' cache.'); | ||
$obBar = $this->output->createProgressBar($obModel::active()->count()); | ||
|
||
foreach ($obModel::active()->orderBy('id')->cursor() as $obRecord) { | ||
$obModelItem::make($obRecord->id); | ||
$obBar->advance(); | ||
unset($obRecord); | ||
} | ||
|
||
$iChunkCount = $obModel::active()->count(); | ||
$iChunkCount = $iChunkCount / $this->argument('chunks'); | ||
$iChunkCount = round($iChunkCount); | ||
$obBar->finish(); | ||
$this->getOutput()->newLine(2); | ||
|
||
$obModel::active()->chunk($iChunkCount, function($records) use ($obModelItem, $sName) { | ||
foreach ($records as $record) { | ||
$obModelItem::make($record->id); | ||
$this->output->writeln($sName . ' #' . $record->id . ' generated cache.'); | ||
} | ||
}); | ||
unset($obBar); | ||
unset($sName); | ||
unset($obModel); | ||
unset($obModelItem); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,51 @@ | ||
<?php namespace BizMark\Shopahelper\Console\Cache; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
use Lovata\Shopaholic\Models\Brand; | ||
use Lovata\Shopaholic\Classes\Item\BrandItem; | ||
|
||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
|
||
class GenerateBrandsCache extends Command | ||
{ | ||
use CacheHelper; | ||
|
||
/** | ||
* @var string The console command name. | ||
*/ | ||
protected $name = 'shopahelper:cache.brands'; | ||
|
||
/** | ||
* @var string The console command description. | ||
*/ | ||
protected $description = 'Generate cache for brands'; | ||
|
||
/** | ||
* Execute the console command. | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$this->generateCache('Brand', Brand::class, BrandItem::class); | ||
} | ||
|
||
/** | ||
* Get the console command arguments. | ||
* @return array | ||
*/ | ||
protected function getArguments() | ||
{ | ||
return [ | ||
['chunks', InputArgument::REQUIRED, 'How many chunks of each collection to iterate. (2, 3, 4 and etc.)'], | ||
]; | ||
} | ||
|
||
/** | ||
* Get the console command options. | ||
* @return array | ||
*/ | ||
protected function getOptions() | ||
{ | ||
return []; | ||
} | ||
} | ||
<?php namespace BizMark\Shopahelper\Console\Cache; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
use Lovata\Shopaholic\Models\Brand; | ||
use Lovata\Shopaholic\Classes\Item\BrandItem; | ||
|
||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
|
||
class GenerateBrandsCache extends Command | ||
{ | ||
use CacheHelper; | ||
|
||
/** | ||
* @var string The console command name. | ||
*/ | ||
protected $name = 'shopahelper:cache.brands'; | ||
|
||
/** | ||
* @var string The console command description. | ||
*/ | ||
protected $description = 'Generate cache for brands'; | ||
|
||
/** | ||
* Execute the console command. | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$this->generateCache('Brand', Brand::class, BrandItem::class); | ||
} | ||
|
||
/** | ||
* Get the console command arguments. | ||
* @return array | ||
*/ | ||
protected function getArguments() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the console command options. | ||
* @return array | ||
*/ | ||
protected function getOptions() | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.