/** * verify * - shipping price group is excluded when it should be */ public function testBuildOrderItemsWithNoShippingPriceGroup() { $handler = $this->getModelMockBuilder('ebayenterprise_order/create_orderitem')->setMethods(['loadOrderItemOptions', 'prepareMerchandisePricing', 'prepareShippingPriceGroup'])->setConstructorArgs([['shipping_helper' => $this->shippingHelper]])->getMock(); $handler->expects($this->any())->method('loadOrderItemOptions')->will($this->returnValue($this->optionValueCollectionStub)); $handler->expects($this->any())->method('prepareMerchandisePricing')->will($this->returnSelf()); $handler->expects($this->never())->method('prepareShippingPriceGroup')->will($this->returnSelf()); // add fake color option value $this->optionValueCollectionStub->addItem(Mage::getModel('eav/entity_attribute_option', ['attribute_code' => 'color', 'option_id' => 15, 'value' => 'Black', 'default_value' => null])); $handler->buildOrderItem($this->payload, $this->itemStub, $this->orderStub, $this->addressStub, 1, false); }
/** * Set collection parameters * * @param Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection $collection * @return Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection */ public function prepareCollection(Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection $collection) { if ($this->_pageSize && $this->_currentPage) { $collection->setPageSize($this->_pageSize)->setCurPage($this->_currentPage)->setOrder('main_table.sort_order', Zend_Db_Select::SQL_ASC); if (array_key_exists('sort_alpha_value', $collection->getSelect()->getPart(Zend_Db_Select::FROM))) { $collection->addOrder('sort_alpha_value.value', Zend_Db_Select::SQL_ASC); } $collection->setFlag(self::FLAG_REVERT_COLLECTION, true); } return $collection; }
* If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Catalog * @subpackage Test * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /* Create attribute */ $installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup'); $attribute = new Mage_Catalog_Model_Resource_Eav_Attribute(); $attribute->setData(array('attribute_code' => 'attribute_with_option', 'entity_type_id' => $installer->getEntityTypeId('catalog_product'), 'is_global' => 1, 'frontend_input' => 'select', 'is_filterable' => 1, 'option' => array('value' => array('option_0' => array(0 => 'Option Label'))), 'backend_type' => 'int')); $attribute->save(); /* Assign attribute to attribute set */ $installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId()); /* Create simple products per each option */ $options = new Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection(); $options->setAttributeFilter($attribute->getId()); foreach ($options as $option) { $product = new Mage_Catalog_Model_Product(); $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setWebsiteIds(array(1))->setName('Simple Product ' . $option->getId())->setSku('simple_product_' . $option->getId())->setPrice(10)->setCategoryIds(array(2))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setStockData(array('use_config_manage_stock' => 1, 'qty' => 5, 'is_in_stock' => 1))->save(); Mage::getSingleton('Mage_Catalog_Model_Product_Action')->updateAttributes(array($product->getId()), array($attribute->getAttributeCode() => $option->getId()), $product->getStoreId()); }
/** * Returns true if given option collection has store filter applied to select values per store. * * If so, the pagination must not be applied * * @see IntegerNet_AttributeOptionPager_Model_Observer::setPageOnCollection() * @see Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection::setStoreFilter() * * @param Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection $collection * @return bool * @throws Zend_Db_Select_Exception */ public function isOptionCollectionStoreFiltered(Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection $collection) { $joins = $collection->getSelect()->getPart(Zend_Db_Select::FROM); return array_key_exists('tsv', $joins) || array_key_exists('tdv', $joins); }
* It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Checkout * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ require __DIR__ . '/../../Catalog/_files/product_configurable.php'; /** @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ /** @var $product Mage_Catalog_Model_Product */ $product = Mage::getModel('Mage_Catalog_Model_Product'); $product->load(1); $options = new Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection(); $option = $options->setAttributeFilter($attribute->getId())->getFirstItem(); $requestInfo = new Varien_Object(array('qty' => 1, 'super_attribute' => array($attribute->getId() => $option->getId()))); /** @var $cart Mage_Checkout_Model_Cart */ $cart = Mage::getModel('Mage_Checkout_Model_Cart'); $cart->addProduct($product, $requestInfo); $cart->save(); Mage::unregister('_singleton/Mage_Checkout_Model_Session');