本文整理汇总了PHP中Magento\Catalog\Test\Fixture\CatalogProductAttribute::getOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP CatalogProductAttribute::getOptions方法的具体用法?PHP CatalogProductAttribute::getOptions怎么用?PHP CatalogProductAttribute::getOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Test\Fixture\CatalogProductAttribute
的用法示例。
在下文中一共展示了CatalogProductAttribute::getOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSearchValue
/**
* Get search value for product attribute.
*
* @param CatalogProductAttribute $attribute
* @return string
*/
protected function getSearchValue(CatalogProductAttribute $attribute)
{
$searchValue = '';
switch ($attribute->getFrontendInput()) {
case 'Multiple Select':
case 'Dropdown':
foreach ($attribute->getOptions() as $option) {
if ($option['is_default'] == 'Yes') {
$searchValue = $option['admin'];
}
}
break;
case 'Text Field':
$searchValue = $attribute->getDefaultValueText();
break;
case 'Text Area':
$searchValue = $attribute->getDefaultValueTextarea();
break;
case 'Date':
$searchValue = $attribute->getDefaultValueDate();
break;
case 'Yes/No':
$searchValue = $attribute->getDefaultValueYesno();
break;
}
return $searchValue;
}
示例2: processAssert
/**
* Assert all product attribute options on product creation form.
*
* @param InjectableFixture $product
* @param CatalogProductIndex $productGrid
* @param CatalogProductAttribute $attribute
* @param CatalogProductEdit $productEdit
* @return void
*/
public function processAssert(InjectableFixture $product, CatalogProductIndex $productGrid, CatalogProductAttribute $attribute, CatalogProductEdit $productEdit)
{
$productGrid->open();
$productGrid->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
$attributeOptions = $attribute->getOptions();
$options[] = $attribute->getFrontendLabel();
foreach ($attributeOptions as $option) {
$options[] = $option['admin'];
}
$productAttributeOptions = $productEdit->getProductForm()->getAttributeElement($attribute)->getText();
$productOptions = explode("\n", $productAttributeOptions);
$diff = array_diff($options, $productOptions);
\PHPUnit_Framework_Assert::assertTrue(empty($diff), "Products attribute options are absent on product form: " . implode(', ', $diff));
}