本文整理汇总了PHP中Mage_Catalog_Model_Product::isConfigurable方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::isConfigurable方法的具体用法?PHP Mage_Catalog_Model_Product::isConfigurable怎么用?PHP Mage_Catalog_Model_Product::isConfigurable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product::isConfigurable方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItemAttributes
public function getItemAttributes()
{
$productType = $this->product->getTypeId();
switch ($productType) {
case Mage_Catalog_Model_Product_Type::TYPE_SIMPLE:
$this->item['attributes'] = $this->getProductCustomOptionsOption($this->product);
break;
case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
if ($this->product->getTypeInstance(true)->hasOptions($this->product)) {
$this->item['attributes'] = $this->getProductBundleOptions($this->product);
}
break;
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE:
if ($this->product->isConfigurable()) {
$this->item['attributes'] = $this->getProductOptions($this->product);
}
break;
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED:
$this->item['attributes'] = $this->getProductGroupedOptions($this->product);
break;
case Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE:
// downloadable/catalog_product_links
$this->item['attributes'] = $this->getProductDownloadOptions($this->product);
break;
case Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL:
$this->item['attributes'] = array();
break;
default:
$this->item['attributes'] = array();
break;
}
return $this->item['attributes'];
}
示例2: testIsConfigurable
/**
* @covers Mage_Catalog_Model_Product::isConfigurable
* @covers Mage_Catalog_Model_Product::isSuperConfig
* @covers Mage_Catalog_Model_Product::isSuper
*/
public function testIsConfigurable()
{
$this->assertFalse($this->_model->isConfigurable());
$this->assertFalse($this->_model->isSuperConfig());
$this->assertFalse($this->_model->isSuper());
$this->_model->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
$this->assertTrue($this->_model->isConfigurable());
$this->assertTrue($this->_model->isSuperConfig());
$this->assertTrue($this->_model->isSuper());
}
示例3: _initConfigurableAttributesData
protected function _initConfigurableAttributesData(Mage_Catalog_Model_Product $mainProduct, $simpleProductIds, $priceChanges = array(), $configurableAttributes = array())
{
if (!$mainProduct->isConfigurable() || empty($simpleProductIds)) {
return $this;
}
$mainProduct->setConfigurableProductsData(array_flip($simpleProductIds));
$productType = $mainProduct->getTypeInstance(true);
$productType->setProduct($mainProduct);
$attributesData = $productType->getConfigurableAttributesAsArray();
if (empty($attributesData)) {
// Auto generation if configurable product has no attribute
$attributeIds = array();
foreach ($productType->getSetAttributes() as $attribute) {
if ($productType->canUseAttribute($attribute)) {
$attributeIds[] = $attribute->getAttributeId();
}
}
$productType->setUsedProductAttributeIds($attributeIds);
$attributesData = $productType->getConfigurableAttributesAsArray();
}
if (!empty($configurableAttributes)) {
foreach ($attributesData as $idx => $val) {
if (!in_array($val['attribute_id'], $configurableAttributes)) {
unset($attributesData[$idx]);
}
}
}
$products = Mage::getModel('catalog/product')->getCollection()->addIdFilter($simpleProductIds);
if (count($products)) {
foreach ($attributesData as $i => $attribute) {
$attribute['label'] = $attribute['frontend_label'];
$attributeCode = $attribute['attribute_code'];
foreach ($products as $product) {
$product->load($product->getId());
$optionId = $product->getData($attributeCode);
$isPercent = 0;
$priceChange = 0;
if (!empty($priceChanges) && isset($priceChanges[$attributeCode])) {
$optionText = $product->getResource()->getAttribute($attribute['attribute_code'])->getSource()->getOptionText($optionId);
if (isset($priceChanges[$attributeCode][$optionText])) {
if (false !== strpos($priceChanges[$attributeCode][$optionText], '%')) {
$isPercent = 1;
}
$priceChange = preg_replace('/[^0-9\\.,-]/', '', $priceChanges[$attributeCode][$optionText]);
$priceChange = (double) str_replace(',', '.', $priceChange);
}
}
$attribute['values'][$optionId] = array('value_index' => $optionId, 'is_percent' => $isPercent, 'pricing_value' => $priceChange);
}
$attributesData[$i] = $attribute;
}
$mainProduct->setConfigurableAttributesData($attributesData);
}
return $this;
}
示例4: setDisplayType
/**
* @return string|void
*/
public function setDisplayType()
{
if ($this->item->isGrouped()) {
parent::setDisplayType(Shopgate_Model_Catalog_Product::DISPLAY_TYPE_LIST);
}
if ($this->item->isConfigurable()) {
parent::setDisplayType(Shopgate_Model_Catalog_Product::DISPLAY_TYPE_SELECT);
}
if ($this->item->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
parent::setDisplayType(Shopgate_Model_Catalog_Product::DISPLAY_TYPE_SIMPLE);
}
}
示例5: getProductData
/**
* Create Product array from Mage_Catalog_Model_Product
*
* @param Mage_Catalog_Model_Product $product
* @return array
*/
public function getProductData(Mage_Catalog_Model_Product $product)
{
try {
$data = array('url' => $product->getProductUrl(), 'title' => htmlspecialchars($product->getName()), 'spider' => 1, 'price' => $product->getPrice(), 'description' => urlencode($product->getDescription()), 'tags' => htmlspecialchars($product->getMetaKeyword()), 'images' => array(), 'vars' => array('sku' => $product->getSku(), 'storeId' => '', 'typeId' => $product->getTypeId(), 'status' => $product->getStatus(), 'categoryId' => $product->getCategoryId(), 'categoryIds' => $product->getCategoryIds(), 'websiteIds' => $product->getWebsiteIds(), 'storeIds' => $product->getStoreIds(), 'groupPrice' => $product->getGroupPrice(), 'formatedPrice' => $product->getFormatedPrice(), 'calculatedFinalPrice' => $product->getCalculatedFinalPrice(), 'minimalPrice' => $product->getMinimalPrice(), 'specialPrice' => $product->getSpecialPrice(), 'specialFromDate' => $product->getSpecialFromDate(), 'specialToDate' => $product->getSpecialToDate(), 'relatedProductIds' => $product->getRelatedProductIds(), 'upSellProductIds' => $product->getUpSellProductIds(), 'getCrossSellProductIds' => $product->getCrossSellProductIds(), 'isSuperGroup' => $product->isSuperGroup(), 'isGrouped' => $product->isGrouped(), 'isConfigurable' => $product->isConfigurable(), 'isSuper' => $product->isSuper(), 'isSalable' => $product->isSalable(), 'isAvailable' => $product->isAvailable(), 'isVirtual' => $product->isVirtual(), 'isRecurring' => $product->isRecurring(), 'isInStock' => $product->isInStock(), 'weight' => $product->getSku()));
// Add product images
if (self::validateProductImage($product->getImage())) {
$data['images']['full'] = array("url" => $product->getImageUrl());
}
if (self::validateProductImage($product->getSmallImage())) {
$data['images']['smallImage'] = array("url" => $product->getSmallImageUrl($width = 88, $height = 77));
}
if (self::validateProductImage($product->getThumbnail())) {
$data['images']['thumb'] = array("url" => $product->getThumbnailUrl($width = 75, $height = 75));
}
return $data;
return $data;
} catch (Exception $e) {
Mage::logException($e);
}
}
示例6: getEditables
/**
* Return list of attributes which can be edited
*
* @param Mage_Catalog_Model_Product $product Product
* @return array List of Mage_Catalog_Model_Resource_Eav_Attribute entities
*/
public function getEditables($product)
{
$setId = $product->getAttributeSetId();
$isConfigurable = $product->isConfigurable();
$attrs = $this->_getAttrs($setId);
$allow = $this->_getAllowedAttrsByUser();
$ignore = $isConfigurable ? $this->_configurableBlacklist : array();
//Add QTY pseudo-attribute before filtering so filtering rules can be
//applied for it
$attrs['qty'] = $this->_getQtyPseudoAttr($isConfigurable);
//Remove attributes which are used in configurable attributes so they
//won't appear in the fronend editor
if ($isConfigurable) {
$attrs = $this->_removeConfigurableAttrs($attrs, $product);
}
$_attrs = array();
foreach ($attrs as $attr) {
if ((!$attr->getId() || $attr->isInSet($setId)) && $this->_isAllowedAttribute($attr, $allow, $ignore)) {
$_attrs[$attr->getAttributeCode()] = $attr;
}
}
return $_attrs;
}
示例7: showLinks
/**
* Returns HTML with attribute images
*
* @param Mage_Catalog_Model_Product $product
* @param string $mode (view, list, grid)
* @param array $names arrtibute codes to show images for
* @param bool $exclude flag to indicate taht we need to show all attributes beside specified in $names
* @return string
*/
public function showLinks($product, $mode = 'view', $names = array(), $exclude = false)
{
$filters = $this->_getFilters();
$items = array();
foreach ($filters as $filter) {
$code = $filter->getAttributeCode();
if (!$code) {
continue;
}
if ($names && in_array($code, $names) && $exclude) {
continue;
}
if ($names && !in_array($code, $names) && !$exclude) {
continue;
}
$optIds = trim($product->getData($code), ',');
if (!$optIds && $product->isConfigurable()) {
$usedProds = $product->getTypeInstance(true)->getUsedProducts(null, $product);
foreach ($usedProds as $child) {
if ($child->getData($code)) {
$optIds .= $child->getData($code) . ',';
}
}
}
if ($optIds) {
$optIds = explode(',', $optIds);
$optIds = array_unique($optIds);
$iconsData = $this->getIconsData();
foreach ($optIds as $id) {
if (isset($iconsData[$id])) {
$items[] = $iconsData[$id];
}
}
}
}
//sort by position in the layered navigation
usort($items, array('Amasty_Shopby_Helper_Data', '_srt'));
//create block
$block = Mage::getModel('core/layout')->createBlock('core/template')->setArea('frontend')->setTemplate('amasty/amshopby/links.phtml');
$block->assign('_type', 'html')->assign('_section', 'body')->setLinks($items)->setMode($mode);
// to be able to created different html
return $block->toHtml();
}
示例8: loadAssocIds
/**
* Fetch associated products ids of configurable product.
* Filtered by current store_id (website_id) and status (enabled).
*
* @param Mage_Catalog_Model_Product $product
* @param string $store_id
* @return array | false
*/
public function loadAssocIds($product, $store_id)
{
$as = false;
$assoc_ids = array();
if ($product->isConfigurable() || $product->getTypeId() == RocketWeb_GoogleBaseFeedGenerator_Model_Map_Product_Subscription_Configurable::PRODUCT_TYPE_SUBSCTIPTION_CONFIGURABLE) {
$as = $this->getTools()->getConfigurableChildsIds($product->getId());
} elseif ($product->isGrouped() || $product->getTypeId() == RocketWeb_GoogleBaseFeedGenerator_Model_Map_Product_Subscription_Grouped::PRODUCT_TYPE_SUBSCTIPTION_GROUPED) {
$as = $this->getTools()->getGroupedChildsIds($product->getId());
}
if ($as === false) {
return $assoc_ids;
}
$as = $this->getTools()->getProductInStoresIds($as);
foreach ($as as $assocId => $s) {
$attribute = $this->getGenerator()->getAttribute('status');
$status = $this->getTools()->getProductAttributeValueBySql($attribute, $attribute->getBackendType(), $assocId, $store_id);
if ($status != Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
continue;
}
if (is_array($s) && array_search($store_id, $s) !== false) {
$assoc_ids[] = $assocId;
}
}
return $assoc_ids;
}
示例9: _createSkus
/**
* @param Mage_Catalog_Model_Product $product
* @return array
*/
protected function _createSkus(Mage_Catalog_Model_Product $product)
{
$base_skus = array();
if ($product->isConfigurable()) {
/** @var $type Mage_Catalog_Model_Product_Type_Configurable */
$type = $product->getTypeInstance();
$attributeCodes = array();
foreach ($type->getConfigurableAttributesAsArray() as $value) {
// Mage::log('attributes configurable: ' . print_r($value, true), null, 'debug.log', true);
// Mage::log('attribute_code: ' . $value['attribute_code'], null, 'debug.log', true);
$attributeCodes[] = array('code' => $value['attribute_code'], 'label' => $value['label'], 'id' => $value['attribute_id']);
foreach ($value['values'] as $val) {
// Mage::log('store_label: ' . $val['store_label'], null, 'debug.log', true);
}
}
$groups = $type->getChildrenIds($product->getId());
// Mage::log("groups: " . print_r($groups, true), null, 'debug.log', true);
foreach ($groups as $group) {
foreach ($group as $childId) {
/** @var $childProduct Mage_Catalog_Model_Product */
$childProduct = Mage::getModel('catalog/product')->load($childId);
$attributes = array();
foreach ($attributeCodes as $array) {
// $attributes[$array['code']] = array('value' => $childProduct->getAttributeText($array['code']),
// 'name' => $array['label']);
$attributes[] = $childProduct->getTypeInstance(true)->getAttributeById($array['id'], $childProduct);
}
$attributes = $this->_createAttributes($childProduct, $attributes);
$base_skus[] = array('sku' => $childProduct->getSku(), 'attributes' => $attributes);
}
}
} else {
$base_skus[] = array('sku' => $product->getSku());
}
$stack = array($base_skus);
// Mage::log(print_r($stack, true), null, 'debug.log', true);
$skus = $this->_findAllSkus($stack);
// Mage::log(print_r($skus, true), null, 'debug.log', true);
// TODO: Need to test this case again
// $sku = $product->getSku();
// if(!isset($sku)) {
// return array();
// }
$data = array();
foreach ($skus as $node) {
$sku = $node['sku'];
$attributes = $node['attributes'];
$data[] = $this->_createSku($sku, $attributes);
}
return $data;
}
示例10: _setAttributes
/**
* set attributes for the product
*
* @param Mage_Catalog_Model_Product $product
*
* @return bool
*/
protected function _setAttributes(Mage_Catalog_Model_Product $product)
{
$tmpProduct = null;
if ($this->_parentProduct && $this->_parentProduct->isConfigurable()) {
$tmpProduct = $this->_parentProduct;
} else {
if ($product->isConfigurable()) {
$tmpProduct = $product;
} else {
return false;
}
}
// Create a stack with all attribute-codes
// fetching it on every item it get very high memory usage on some systems
if (!isset($this->_stack[$tmpProduct->getId()])) {
$productTypeInstance = $tmpProduct->getTypeInstance(true);
if ($productTypeInstance == null || !method_exists($productTypeInstance, "getUsedProducts")) {
return false;
}
$allowAttributes = $productTypeInstance->getConfigurableAttributes($tmpProduct);
$this->_stack[$tmpProduct->getId()] = $allowAttributes;
}
$i = 0;
if ($this->_parentProduct) {
foreach ($this->_stack[$this->_parentProduct->getId()] as $attribute) {
$i++;
$attribute = $attribute->getProductAttribute();
if ($attribute == null) {
continue;
}
$attribute = $attribute->getAttributeCode();
$attrValue = $product->getResource()->getAttribute($attribute)->getFrontend();
$this->_defaultRow["attribute_{$i}"] = $attrValue->getValue($product);
}
} else {
if ($product->isConfigurable()) {
foreach ($this->_stack[$product->getId()] as $attribute) {
$i++;
$this->_defaultRow["attribute_{$i}"] = $attribute->getLabel();
}
}
}
}
示例11: getPriceDeltas
/**
* Get a price deltas array
*
* @param Mage_Catalog_Model_Product $product
* @return QVC_ConfigurableAutoPricing_Model_PriceChanges
*/
public function getPriceDeltas(Mage_Catalog_Model_Product $product)
{
if (isset($this->_deltas[$product->getId()])) {
return $this->_deltas[$product->getId()];
}
if (!$product->isConfigurable()) {
return null;
}
/**
* Get product attributes
*/
$attributesArray = $this->getConfigurableAttributesArray($product);
/**
* Parse children to get absolute prices
*/
$prices = array();
$minPrice = null;
$minChild = null;
$children = $this->getProductChildren($product);
if (empty($children)) {
return null;
}
foreach ($children as $child) {
$currentPrice = $this->getActualPrice($child);
foreach ($attributesArray as $attributeCode) {
$prices[$attributeCode][$child->getData($attributeCode)][] = $currentPrice;
}
/**
* If the price for the deltas should be the minimum price, put it into vars
*/
if ($currentPrice < $minPrice || $minPrice === null) {
$minPrice = $currentPrice;
$minChild = $child;
}
}
/**
* If the price shouldn't be taken from the children, take it from the parent
*/
if (!Mage::getStoreConfigFlag(self::CONFIG_XPATH_PARENT_PRICE)) {
$minPrice = $this->getActualPrice($product);
$minChild = $product;
}
/**
* Parse absolute prices to get price deltas
* @var QVC_ConfigurableAutoPricing_Model_PriceChanges $priceChanges
*/
$priceChanges = Mage::getModel('qvc_configurableautopricing/priceChanges');
foreach ($prices as $attributeCode => $attribute) {
foreach ($attribute as $attributeValue => $attributePrices) {
$attributePrices = array_unique($attributePrices);
if (count($attributePrices) == 1) {
$delta = $attributePrices[0] - $minPrice;
} else {
$delta = 0;
}
$priceChanges->setPriceDelta($attributeCode, $attributeValue, $delta);
}
}
$priceChanges->setPriceFromChild($minChild);
$this->_deltas[$product->getId()] = $priceChanges;
return $priceChanges;
}
示例12: _initConfigurableAttributesData
/**
* @param Mage_Catalog_Model_Product $mainProduct
* @param array $simpleProductIds
* @param array $priceChanges
* @return JR_Api_Helper_Catalog_Product
*/
protected function _initConfigurableAttributesData(Mage_Catalog_Model_Product $mainProduct, $simpleProductIds, $priceChanges = array(), $configAttributes = array())
{
if (!$mainProduct->isConfigurable() || empty($simpleProductIds)) {
return $this;
}
$mainProduct->setConfigurableProductsData(array_flip($simpleProductIds));
$productType = $mainProduct->getTypeInstance(true);
$productType->setProduct($mainProduct);
// Get attributes already associated to this product
$used_attr_codes = array();
foreach ($productType->getConfigurableAttributesAsArray($mainProduct) as $attr) {
$used_attr_codes[] = $attr['attribute_code'];
}
// Add only the new attributes to this product
$new_attr_ids = array();
foreach ($productType->getSetAttributes() as $attribute) {
if ($productType->canUseAttribute($attribute)) {
if (!empty($configAttributes) && in_array($attribute->getAttributeCode(), $configAttributes) && !in_array($attribute->getAttributeCode(), $used_attr_codes)) {
$new_attr_ids[] = $attribute->getAttributeId();
}
}
}
$productType->setUsedProductAttributeIds($new_attr_ids);
$attributesData = $productType->getConfigurableAttributesAsArray();
// Update 'association' attributes
$products = Mage::getModel('catalog/product')->getCollection()->addIdFilter($simpleProductIds);
if (count($products)) {
foreach ($attributesData as &$attribute) {
$attribute['label'] = $attribute['frontend_label'];
$attributeCode = $attribute['attribute_code'];
foreach ($products as $product) {
$product->load($product->getId());
$optionId = $product->getData($attributeCode);
$isPercent = 0;
$priceChange = 0;
if (!empty($priceChanges) && isset($priceChanges[$attributeCode])) {
$optionText = $product->getResource()->getAttribute($attribute['attribute_code'])->getSource()->getOptionText($optionId);
if (isset($priceChanges[$attributeCode][$optionText])) {
if (false !== strpos($priceChanges[$attributeCode][$optionText], '%')) {
$isPercent = 1;
}
$priceChange = preg_replace('/[^0-9\\.,-]/', '', $priceChanges[$attributeCode][$optionText]);
$priceChange = (double) str_replace(',', '.', $priceChange);
}
}
$attribute['values'][$optionId] = array('value_index' => $optionId, 'is_percent' => $isPercent, 'pricing_value' => $priceChange);
}
}
$mainProduct->setConfigurableAttributesData($attributesData);
}
//
// $log_file = "/home/sourismini/magento_app/prod/var/log/soap.log";
// $log = print_r(array_flip($simpleProductIds), true);
// file_put_contents($log_file, $log, FILE_APPEND);
//
return $this;
}