本文整理汇总了PHP中Mage_Catalog_Model_Product_Option::groupFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product_Option::groupFactory方法的具体用法?PHP Mage_Catalog_Model_Product_Option::groupFactory怎么用?PHP Mage_Catalog_Model_Product_Option::groupFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product_Option
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product_Option::groupFactory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: groupFactory
public function groupFactory($type)
{
//if (!Mage::helper('giftcard')->isActive())
// return parent::groupFactory($type);
if ($type === self::OPTION_TYPE_GIFT_CARD_VALUE) {
return Mage::getModel('giftcard/catalog_product_option_type_giftcardvalue');
}
return parent::groupFactory($type);
}
示例2: _uploadPhoto
/**
*
* @param string $filename
* @param resource $image
* @param Mage_Catalog_Model_Product_Option $option
*/
protected function _uploadPhoto($filename, $image, $option)
{
$result = array();
$optionFile = $option->groupFactory($option->getType());
$extension = pathinfo(strtolower($filename), PATHINFO_EXTENSION);
$filename = Mage_Core_Model_File_Uploader::getCorrectFileName($filename);
$dispersion = Mage_Core_Model_File_Uploader::getDispretionPath($filename);
$quoteDir = $optionFile->getQuoteTargetDir() . $dispersion;
$uploadDir = Mage::helper('aydus_customconfigurable')->getMediaDir() . DS . $dispersion;
if (!file_exists($quoteDir)) {
mkdir($quoteDir, 0775, true);
}
if (!file_exists($uploadDir)) {
mkdir($uploadDir, 0775, true);
}
$hash = md5($image);
$filenameHash = $hash . '.' . $extension;
$quoteFilePath = $quoteDir . DS . $filenameHash;
$size = file_put_contents($quoteFilePath, $image);
$result['error'] = $size > 0 ? false : true;
if ($result['error']) {
$result['data'] = 'File upload failed';
} else {
$time = time();
$uploadFilePath = $uploadDir . DS . $time . '-' . $filename;
if (copy($quoteFilePath, $uploadFilePath)) {
$result['data'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'aydus' . DS . 'customconfigurable' . $dispersion . DS . $time . '-' . $filename;
} else {
$result['error'] = true;
$result['data'] = 'Could not copy uploaded image to ' . $uploadFilePath . '; check permissions';
}
}
return $result;
}