Skip to content

Commit

Permalink
Merge pull request #256 from oc-shopaholic/develop
Browse files Browse the repository at this point in the history
Release version 1.26.0
  • Loading branch information
kharanenka authored Mar 2, 2020
2 parents a1154e6 + 185bfb1 commit fce3900
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 5 deletions.
7 changes: 7 additions & 0 deletions classes/event/offer/ExtendOfferFieldsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ class ExtendOfferFieldsHandler extends AbstractBackendFieldHandler
protected function extendFields($obWidget)
{
$arAdditionFields = [
'measure' => [
'label' => 'lovata.shopaholic::lang.field.measure',
'type' => 'relation',
'span' => 'left',
'emptyOption' => 'lovata.toolbox::lang.field.empty',
'tab' => 'lovata.shopaholic::lang.tab.dimensions',
],
'weight' => [
'label' => $this->getWeightFieldLabel(),
'type' => 'number',
Expand Down
6 changes: 6 additions & 0 deletions classes/item/OfferItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* @property double $length
* @property double $width
* @property double $quantity_in_unit
* @property int $measure_id
* @property MeasureItem $measure
* @property int $measure_of_unit_id
* @property MeasureItem $measure_of_unit
* @property MeasureItem $dimensions_measure
Expand Down Expand Up @@ -115,6 +117,10 @@ class OfferItem extends ElementItem
'class' => ProductItem::class,
'field' => 'product_id',
],
'measure' => [
'class' => MeasureItem::class,
'field' => 'measure_id',
],
'measure_of_unit' => [
'class' => MeasureItem::class,
'field' => 'measure_of_unit_id',
Expand Down
4 changes: 2 additions & 2 deletions components/BrandPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class BrandPage extends ElementPage
{
protected $bNeedSmartURLCheck = true;

/** @var \Lovata\Shopaholic\Models\Brand */
/** @var Brand */
protected $obElement;

/** @var \Lovata\Shopaholic\Classes\Item\BrandItem */
/** @var BrandItem */
protected $obElementItem;

/**
Expand Down
10 changes: 8 additions & 2 deletions models/Offer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* @property double $length
* @property double $width
* @property double $quantity_in_unit
* @property int $measure_id
* @property int $measure_of_unit_id
* @property int $product_id
* @property \October\Rain\Argon\Argon $created_at
Expand All @@ -67,6 +68,8 @@
*
* @property Measure $measure_of_unit
* @method static \October\Rain\Database\Relations\BelongsTo|Measure measure_of_unit()
* @property Measure $measure
* @method static \October\Rain\Database\Relations\BelongsTo|Measure measure()
*
* @method static $this getByProduct(int $iProductID)
* @method static $this getByQuantity(int $iCount, string $sCondition = '=')
Expand Down Expand Up @@ -151,6 +154,7 @@ class Offer extends ImportModel
public $belongsTo = [
'product' => [Product::class],
'measure_of_unit' => [Measure::class, 'key' => 'measure_of_unit_id', 'order' => 'name asc'],
'measure' => [Measure::class, 'order' => 'name asc'],
];
public $morphMany = [
'price_link' => [
Expand Down Expand Up @@ -185,6 +189,7 @@ class Offer extends ImportModel
'length',
'width',
'measure_of_unit_id',
'measure_id',
'quantity_in_unit',
];

Expand All @@ -205,6 +210,7 @@ class Offer extends ImportModel
'length',
'width',
'measure_of_unit_id',
'measure_id',
'quantity_in_unit',
];

Expand Down Expand Up @@ -447,8 +453,8 @@ protected function getPriceListAttribute()

foreach ($this->price_link as $obPrice) {
$arResult[$obPrice->price_type_id] = [
'price' => $obPrice->price,
'old_price' => $obPrice->old_price,
'price' => $obPrice->price_value,
'old_price' => $obPrice->old_price_value,
];
}

Expand Down
4 changes: 4 additions & 0 deletions models/measure/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ fields:
span: left
required: 1
type: text
code:
label: 'lovata.toolbox::lang.field.code'
span: right
type: text
42 changes: 42 additions & 0 deletions updates/update_table_offers_add_measure_field.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php namespace Lovata\Shopaholic\Updates;

use Schema;
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;

/**
* Class UpdateTableOffersAddMeasureField
* @package Lovata\Shopaholic\Updates
*/
class UpdateTableOffersAddMeasureField extends Migration
{
const TABLE_NAME = 'lovata_shopaholic_offers';

/**
* Apply migration
*/
public function up()
{
if (!Schema::hasTable(self::TABLE_NAME) || Schema::hasColumn(self::TABLE_NAME, 'measure_id')) {
return;
}

Schema::table(self::TABLE_NAME, function (Blueprint $obTable) {
$obTable->integer('measure_id')->nullable()->after('quantity');
});
}

/**
* Rollback migration
*/
public function down()
{
if (!Schema::hasTable(self::TABLE_NAME) || !Schema::hasColumn(self::TABLE_NAME, 'measure_id')) {
return;
}

Schema::table(self::TABLE_NAME, function (Blueprint $obTable) {
$obTable->dropColumn(['measure_id']);
});
}
}
5 changes: 4 additions & 1 deletion updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,7 @@
1.25.0:
- 'Moved "Measure" model from "Properties for Shopaholic" plugin. Added weight, height, length, width, measure_of_unit, quantity_in_unit fields to Offer model. Added new global settings: size unit measure, weight unit measure, piece unit measure.'
- create_table_measure.php
- update_table_offers_add_dimensions_field.php
- update_table_offers_add_dimensions_field.php
1.26.0:
- 'Added relation to Offer model with Measure model.'
- update_table_offers_add_measure_field.php

0 comments on commit fce3900

Please sign in to comment.