Skip to content

Commit 7793933

Browse files
author
Cari Spruiell
committed
MAGETWO-38285: [Add join processors to search service] Catalog Module
- make Product\Option extensible
1 parent 42200be commit 7793933

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

app/code/Magento/Catalog/Api/Data/ProductCustomOptionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* @api
1111
*/
12-
interface ProductCustomOptionInterface extends \Magento\Framework\Api\ExtensibleDataInterface
12+
interface ProductCustomOptionInterface
1313
{
1414
/**
1515
* Get product SKU

app/code/Magento/Catalog/Model/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,7 @@ public function getOptions()
19701970
{
19711971
if (empty($this->_options) && $this->getHasOptions() && !$this->optionsInitialized) {
19721972
$collection = $this->getProductOptionsCollection();
1973-
$this->joinProcessor->process($collection, 'Magento\Catalog\Api\Data\ProductCustomOptionInterface');
1973+
$this->joinProcessor->process($collection);
19741974
foreach ($collection as $option) {
19751975
$option->setProduct($this);
19761976
$this->addOption($option);

app/code/Magento/Catalog/Model/Product/Option.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Catalog\Model\Product;
1313
use Magento\Catalog\Model\Resource\Product\Option\Value\Collection;
1414
use Magento\Catalog\Pricing\Price\BasePrice;
15-
use Magento\Framework\Model\AbstractModel;
1615
use Magento\Framework\Exception\LocalizedException;
1716

1817
/**
@@ -26,7 +25,8 @@
2625
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2726
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
2827
*/
29-
class Option extends AbstractModel implements \Magento\Catalog\Api\Data\ProductCustomOptionInterface
28+
class Option extends \Magento\Framework\Model\AbstractExtensibleModel
29+
implements \Magento\Catalog\Api\Data\ProductCustomOptionInterface
3030
{
3131
const OPTION_GROUP_TEXT = 'text';
3232

@@ -116,6 +116,8 @@ class Option extends AbstractModel implements \Magento\Catalog\Api\Data\ProductC
116116
/**
117117
* @param \Magento\Framework\Model\Context $context
118118
* @param \Magento\Framework\Registry $registry
119+
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
120+
* @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
119121
* @param Option\Value $productOptionValue
120122
* @param Option\Type\Factory $optionFactory
121123
* @param \Magento\Framework\Stdlib\String $string
@@ -128,6 +130,8 @@ class Option extends AbstractModel implements \Magento\Catalog\Api\Data\ProductC
128130
public function __construct(
129131
\Magento\Framework\Model\Context $context,
130132
\Magento\Framework\Registry $registry,
133+
\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
134+
\Magento\Framework\Api\AttributeValueFactory $customAttributeFactory,
131135
Option\Value $productOptionValue,
132136
\Magento\Catalog\Model\Product\Option\Type\Factory $optionFactory,
133137
\Magento\Framework\Stdlib\String $string,
@@ -143,6 +147,8 @@ public function __construct(
143147
parent::__construct(
144148
$context,
145149
$registry,
150+
$extensionFactory,
151+
$customAttributeFactory,
146152
$resource,
147153
$resourceCollection,
148154
$data
@@ -406,7 +412,7 @@ public function saveOptions()
406412
}
407413

408414
/**
409-
* @return AbstractModel
415+
* @return \Magento\Framework\Model\AbstractModel
410416
* @throws \Magento\Framework\Exception\LocalizedException
411417
*/
412418
public function afterSave()

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,4 +419,15 @@ public function testValidate()
419419
$this->assertTrue($error);
420420
}
421421
}
422+
423+
/**
424+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
425+
* @magentoAppIsolation enabled
426+
*/
427+
public function testGetOptions()
428+
{
429+
$this->_model->load(1);
430+
$options = $this->_model->getOptions();
431+
$this->assertEquals(4, count($options));
432+
}
422433
}

0 commit comments

Comments
 (0)