本文整理汇总了PHP中Magento\Catalog\Model\Product\Option::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::getTitle方法的具体用法?PHP Option::getTitle怎么用?PHP Option::getTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Product\Option
的用法示例。
在下文中一共展示了Option::getTitle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateOptionRequiredFields
/**
* Validate option required fields
*
* @param Option $option
* @return bool
*/
protected function validateOptionRequiredFields(Option $option)
{
$storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
$product = $option->getProduct();
if ($product) {
$storeId = $product->getStoreId();
}
$title = $option->getTitle();
return $this->isValidOptionTitle($title, $storeId) && !$this->isEmpty($option->getType());
}
示例2: _getPriceConfiguration
/**
* Get price configuration
*
* @param \Magento\Catalog\Model\Product\Option\Value|\Magento\Catalog\Model\Product\Option $option
* @return array
*/
protected function _getPriceConfiguration($option)
{
$optionPrice = $this->pricingHelper->currency($option->getPrice(true), false, false);
$data = ['prices' => ['oldPrice' => ['amount' => $this->pricingHelper->currency($option->getRegularPrice(), false, false), 'adjustments' => []], 'basePrice' => ['amount' => $this->_catalogData->getTaxPrice($option->getProduct(), $optionPrice, false, null, null, null, null, null, false)], 'finalPrice' => ['amount' => $this->_catalogData->getTaxPrice($option->getProduct(), $optionPrice, true, null, null, null, null, null, false)]], 'type' => $option->getPriceType(), 'name' => $option->getTitle()];
return $data;
}
示例3: buildImageValidator
/**
* @param \Zend_File_Transfer_Adapter_Http|\Zend_Validate $object
* @param \Magento\Catalog\Model\Product\Option $option
* @param array $fileFullPath
* @return \Zend_File_Transfer_Adapter_Http|\Zend_Validate $object
* @throws \Magento\Framework\Exception\InputException
*/
protected function buildImageValidator($object, $option, $fileFullPath = null)
{
$dimensions = [];
if ($option->getImageSizeX() > 0) {
$dimensions['maxwidth'] = $option->getImageSizeX();
}
if ($option->getImageSizeY() > 0) {
$dimensions['maxheight'] = $option->getImageSizeY();
}
if (count($dimensions) > 0) {
if ($fileFullPath !== null && !$this->isImage($fileFullPath)) {
throw new \Magento\Framework\Exception\InputException(__('File \'%1\' is not an image.', $option->getTitle()));
}
$object->addValidator(new \Zend_Validate_File_ImageSize($dimensions));
}
// File extension
$allowed = $this->parseExtensionsString($option->getFileExtension());
if ($allowed !== null) {
$object->addValidator(new \Zend_Validate_File_Extension($allowed));
} else {
$forbidden = $this->parseExtensionsString($this->getConfigData('forbidden_extensions'));
if ($forbidden !== null) {
$object->addValidator(new \Zend_Validate_File_ExcludeExtension($forbidden));
}
}
$object->addValidator(new \Zend_Validate_File_FilesSize(['max' => $this->fileSize->getMaxFileSize()]));
return $object;
}
示例4: validateOptionRequiredFields
/**
* Validate option required fields
*
* @param Option $option
* @return bool
*/
protected function validateOptionRequiredFields(Option $option)
{
return !$this->isEmpty($option->getTitle()) && !$this->isEmpty($option->getType());
}
示例5: _createOptionDataObject
/**
* Create option data object
*
* @param \Magento\Catalog\Model\Product\Option $option
* @return \Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option array
*/
protected function _createOptionDataObject(\Magento\Catalog\Model\Product\Option $option)
{
$data = array(Data\Option::OPTION_ID => $option->getId(), Data\Option::TITLE => $option->getTitle(), Data\Option::TYPE => $option->getType(), Data\Option::IS_REQUIRE => $option->getIsRequire(), Data\Option::SORT_ORDER => $option->getSortOrder(), Data\Option::METADATA => $this->optionMetadataReader->read($option));
return $this->optionBuilder->populateWithArray($data)->create();
}