-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
29 additions
and
22 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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
use Craft; | ||
use craft\base\Field; | ||
use craft\base\FieldLayoutProviderInterface; | ||
use craft\behaviors\FieldLayoutBehavior; | ||
use craft\commerce\base\Model; | ||
use craft\commerce\elements\Product; | ||
|
@@ -33,7 +34,6 @@ | |
/** | ||
* Product type model. | ||
* @method null setFieldLayout(FieldLayout $fieldLayout) | ||
* @method FieldLayout getFieldLayout() | ||
* | ||
* @property string $cpEditUrl | ||
* @property string $cpEditVariantUrl | ||
|
@@ -47,7 +47,7 @@ | |
* @author Pixel & Tonic, Inc. <[email protected]> | ||
* @since 2.0 | ||
*/ | ||
class ProductType extends Model | ||
class ProductType extends Model implements FieldLayoutProviderInterface | ||
{ | ||
/** @since 5.2.0 */ | ||
public const DEFAULT_PLACEMENT_BEGINNING = 'beginning'; | ||
|
@@ -224,6 +224,14 @@ public function __toString() | |
return (string)$this->handle; | ||
} | ||
|
||
/** | ||
* @inerhitdoc | ||
*/ | ||
public function getHandle(): ?string | ||
{ | ||
return $this->handle; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
|
@@ -388,6 +396,11 @@ public function setTaxCategories(array $taxCategories): void | |
$this->_taxCategories = $categories; | ||
} | ||
|
||
public function getFieldLayout(): FieldLayout | ||
{ | ||
return $this->productFieldLayout(); | ||
} | ||
|
||
/** | ||
* @throws InvalidConfigException | ||
*/ | ||
|
@@ -517,9 +530,8 @@ public function getHasVariants(): bool | |
/** | ||
* @inheritdoc | ||
*/ | ||
public function behaviors(): array | ||
protected function defineBehaviors(): array | ||
{ | ||
$behaviors = parent::behaviors(); | ||
$behaviors['productFieldLayout'] = [ | ||
'class' => FieldLayoutBehavior::class, | ||
'elementType' => Product::class, | ||
|