Forked from adrian-martinez-interactiv4/testAbstractExtensibleModel.php
Created
February 28, 2018 15:03
-
-
Save rubenRP/3084bc7d0589e67247fe4371777b5aff to your computer and use it in GitHub Desktop.
testAbstractExtensibleModel.php
This file contains hidden or 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
<?php | |
use Magento\Framework\App\Area; | |
require __DIR__ . '/app/bootstrap.php'; | |
class testAbstractExtensibleModelApp extends \Magento\Framework\App\Http implements \Magento\Framework\AppInterface | |
{ | |
/** | |
* @return \Magento\Framework\App\Response\Http | |
*/ | |
public function launch() | |
{ | |
$this->_state->setAreaCode(Area::AREA_ADMINHTML); | |
$this->_objectManager->configure($this->_configLoader->load(Area::AREA_ADMINHTML)); | |
$productFactory = $this->_objectManager->create(Magento\Catalog\Model\ProductFactory::class); | |
/** @var Magento\Catalog\Model\Product $product */ | |
$product = $productFactory->create(); | |
$customAttributeCode = 'my_custom_attribute'; | |
// Expected to create custom attributes via factory | |
// in \Magento\Framework\Model\AbstractExtensibleModel::initializeCustomAttributes | |
$customAttribute = $product->getCustomAttribute($customAttributeCode); | |
// This change should NOT change customAttributesChanged flag | |
$product->setPrice(46.00); | |
// Expected to NOT recreate custom attributes via factory | |
// in \Magento\Framework\Model\AbstractExtensibleModel::initializeCustomAttributes | |
$customAttribute = $product->getCustomAttribute($customAttributeCode); | |
//the method must end with this line | |
return $this->_response; | |
} | |
/** | |
* @param \Magento\Framework\App\Bootstrap $bootstrap | |
* @param Exception $exception | |
* @return bool | |
*/ | |
public function catchException(\Magento\Framework\App\Bootstrap $bootstrap, \Exception $exception) | |
{ | |
return false; | |
} | |
} | |
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); | |
/** @var \Magento\Framework\App\Http $app */ | |
$app = $bootstrap->createApplication(testAbstractExtensibleModelApp::class); | |
$bootstrap->run($app); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment