本文整理汇总了PHP中Magento\Catalog\Model\Category::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getAttributes方法的具体用法?PHP Category::getAttributes怎么用?PHP Category::getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Category
的用法示例。
在下文中一共展示了Category::getAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAttributes
public function testGetAttributes()
{
$attributes = $this->_model->getAttributes();
$this->assertArrayHasKey('name', $attributes);
$this->assertArrayHasKey('custom_design', $attributes);
$attributes = $this->_model->getAttributes(true);
$this->assertArrayHasKey('name', $attributes);
$this->assertArrayNotHasKey('custom_design', $attributes);
}
示例2: upgrade
/**
* {@inheritdoc}
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
if (version_compare($context->getVersion(), '2.0.0.2') < 0) {
$newBackendModel = 'Magento\\Catalog\\Model\\Attribute\\Backend\\Startdate';
$connection = $setup->getConnection();
$connection->startSetup();
$connection->update($setup->getTable('eav_attribute'), ['backend_model' => $newBackendModel], ['backend_model = ?' => 'Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Startdate']);
/** @var \Magento\Catalog\Model\Resource\Eav\Attribute $attribute */
foreach ($this->category->getAttributes() as $attribute) {
if ($attribute->getAttributeCode() == 'custom_design_from') {
$attribute->setBackendModel($newBackendModel);
$attribute->save();
break;
}
}
$connection->endSetup();
}
}
示例3: dateTimePreprocessing
/**
* Datetime data preprocessing
*
* @param \Magento\Catalog\Model\Category $category
* @param array $postData
*
* @return array
*/
protected function dateTimePreprocessing($category, $postData)
{
$dateFieldFilters = [];
$attributes = $category->getAttributes();
foreach ($attributes as $attrKey => $attribute) {
if ($attribute->getBackend()->getType() == 'datetime') {
if (array_key_exists($attrKey, $postData) && $postData[$attrKey] != '') {
$dateFieldFilters[$attrKey] = $this->getDateTimeFilter();
}
}
}
$inputFilter = new \Zend_Filter_Input($dateFieldFilters, [], $postData);
return $inputFilter->getUnescaped();
}
示例4: getAttributes
/**
* {@inheritdoc}
*/
public function getAttributes($noDesignAttributes = false)
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getAttributes');
if (!$pluginInfo) {
return parent::getAttributes($noDesignAttributes);
} else {
return $this->___callPlugins('getAttributes', func_get_args(), $pluginInfo);
}
}