Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adrian-martinez-interactiv4/17fec6072063d36eb20396f9c32e4c9a to your computer and use it in GitHub Desktop.
Save adrian-martinez-interactiv4/17fec6072063d36eb20396f9c32e4c9a to your computer and use it in GitHub Desktop.
testAbstractExtensibleModel.php
<?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