本文整理汇总了PHP中Magento\Catalog\Model\Category::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::validate方法的具体用法?PHP Category::validate怎么用?PHP Category::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Category
的用法示例。
在下文中一共展示了Category::validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testValidate
public function testValidate()
{
$this->_model->addData(["include_in_menu" => false, "is_active" => false, 'name' => 'test']);
$this->assertNotEmpty($this->_model->validate());
}
示例2: validateCategory
/**
* Validate category process
*
* @param Category $category
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function validateCategory(Category $category)
{
$useConfigFields = [];
foreach ($this->useConfigFields as $field) {
if (!$category->getData($field)) {
$useConfigFields[] = $field;
}
}
$category->setData('use_post_data_config', $useConfigFields);
$validate = $category->validate();
if ($validate !== true) {
foreach ($validate as $code => $error) {
if ($error === true) {
$attribute = $this->categoryResource->getAttribute($code)->getFrontend()->getLabel();
throw new \Magento\Framework\Exception\LocalizedException(__('Attribute "%1" is required.', $attribute));
} else {
throw new \Magento\Framework\Exception\LocalizedException(__($error));
}
}
}
$category->unsetData('use_post_data_config');
}
示例3: validate
/**
* {@inheritdoc}
*/
public function validate()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'validate');
if (!$pluginInfo) {
return parent::validate();
} else {
return $this->___callPlugins('validate', func_get_args(), $pluginInfo);
}
}