当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Object::setStoreId方法代码示例

本文整理汇总了PHP中Varien_Object::setStoreId方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::setStoreId方法的具体用法?PHP Varien_Object::setStoreId怎么用?PHP Varien_Object::setStoreId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Object的用法示例。


在下文中一共展示了Varien_Object::setStoreId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: runConverter

 /**
  * @param Varien_Object $dataObject
  */
 public function runConverter(Varien_Object $dataObject)
 {
     $stylaField = $this->getStylaField();
     $environmentInfo = $this->_emulateFrontend();
     //we need to temporarily set the same store id to the object, or else we won't get a rewritten url
     $oldId = $dataObject->getStoreId();
     $dataObject->setStoreId($this->_getDefaultStoreViewId());
     $productUrl = $dataObject->getProductUrl();
     if ($this->_useRelativeUrls()) {
         $productUrl = str_replace(Mage::getBaseUrl(), "/", $productUrl);
     }
     $dataObject->setStoreId($oldId);
     $this->_stopEmulation($environmentInfo);
     $dataObject->setData($stylaField, $productUrl);
 }
开发者ID:Keesromkes,项目名称:magentoStylaConnect,代码行数:18,代码来源:Url.php

示例2: beforeSave

 /**
  * Before save
  *
  * @param Varien_Object $object
  * @return Mage_Customer_Model_Customer_Attribute_Backend_Store
  */
 public function beforeSave($object)
 {
     if ($object->getId()) {
         return $this;
     }
     if (!$object->hasStoreId()) {
         $object->setStoreId(Mage::app()->getStore()->getId());
     }
     if (!$object->hasData('created_in')) {
         $object->setData('created_in', Mage::app()->getStore($object->getStoreId())->getName());
     }
     return $this;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:19,代码来源:Store.php

示例3: _toHtml

 /**
  * Prepare html output
  *
  * @return string
  */
 protected function _toHtml()
 {
     $previewModel = Mage::getModel('hackathon_emailpreview/emailPreview');
     $storeId = $this->getRequest()->getParam('storeId');
     $templateId = $this->getRequest()->getParam('templateId');
     $templateType = $this->getRequest()->getParam('templateType');
     $templateParams = new Varien_Object();
     $templateParams->setRequestParams($this->getRequest()->getParams());
     $templateParams->setStoreId($storeId);
     $eventData = array('templateParams' => $templateParams, 'templateType' => $templateType);
     Mage::dispatchEvent('hackathon_emailpreview_render_email_before', $eventData);
     $storeId = $templateParams->getStoreId();
     $templateParams->setStore(Mage::app()->getStore($storeId));
     $html = $previewModel->renderEmail($templateId, $templateParams->getData());
     return $html;
 }
开发者ID:xD83d,项目名称:E-MailPreview,代码行数:21,代码来源:PreviewContent.php

示例4: setUpHelperMock

 private function setUpHelperMock($returnStatus, $setStoreId = true)
 {
     $paymentHelperMock = $this->getHelperMock('ops/payment', array('applyStateForOrder', 'shaCryptValidation'));
     $paymentHelperMock->expects($this->any())->method('applyStateForOrder')->will($this->returnValue($returnStatus));
     $paymentHelperMock->expects($this->any())->method('shaCryptValidation')->will($this->returnValue(true));
     $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
     $fakePayment = new Varien_Object();
     $fakePayment->setMethodInstance(Mage::getModel('ops/payment_cc'));
     $fakeOrder = new Varien_Object();
     $fakeOrder->setPayment($fakePayment);
     $fakeOrder->setId(1);
     if ($setStoreId) {
         $fakeOrder->setStoreId(1);
     }
     $orderHelperMock = $this->getHelperMock('ops/order', array('getOrder'));
     $orderHelperMock->expects($this->any())->method('getOrder')->will($this->returnValue($fakeOrder));
     $this->replaceByMock('helper', 'ops/order', $orderHelperMock);
 }
开发者ID:roshu1980,项目名称:add-computers,代码行数:18,代码来源:ApiControllerTest.php

示例5: _afterSave

 /**
  * After save process
  *
  * @param Mage_Core_Model_Abstract $object
  * @return Mage_Bundle_Model_Resource_Option
  */
 protected function _afterSave(Mage_Core_Model_Abstract $object)
 {
     parent::_afterSave($object);
     $condition = array('option_id = ?' => $object->getId(), 'store_id = ? OR store_id = 0' => $object->getStoreId());
     $write = $this->_getWriteAdapter();
     $write->delete($this->getTable('bundle/option_value'), $condition);
     $data = new Varien_Object();
     $data->setOptionId($object->getId())->setStoreId($object->getStoreId())->setTitle($object->getTitle());
     $write->insert($this->getTable('bundle/option_value'), $data->getData());
     /**
      * also saving default value if this store view scope
      */
     if ($object->getStoreId()) {
         $data->setStoreId(0);
         $data->setTitle($object->getDefaultTitle());
         $write->insert($this->getTable('bundle/option_value'), $data->getData());
     }
     return $this;
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:25,代码来源:Option.php

示例6: _afterSave

 /**
  * After save process
  *
  * @param Mage_Core_Model_Abstract $object
  * @return Mage_Bundle_Model_Mysql4_Option
  */
 protected function _afterSave(Mage_Core_Model_Abstract $object)
 {
     parent::_afterSave($object);
     $condition = $this->_getWriteAdapter()->quoteInto('option_id = ?', $object->getId());
     $condition .= ' and (' . $this->_getWriteAdapter()->quoteInto('store_id = ?', $object->getStoreId());
     $condition .= ' or store_id = 0)';
     $this->_getWriteAdapter()->delete($this->getTable('option_value'), $condition);
     $data = new Varien_Object();
     $data->setOptionId($object->getId())->setStoreId($object->getStoreId())->setTitle($object->getTitle());
     $this->_getWriteAdapter()->insert($this->getTable('option_value'), $data->getData());
     /**
      * also saving default value if this store view scope
      */
     if ($object->getStoreId()) {
         $data->setStoreId('0');
         $data->setTitle($object->getDefaultTitle());
         $this->_getWriteAdapter()->insert($this->getTable('option_value'), $data->getData());
     }
     return $this;
 }
开发者ID:jauderho,项目名称:magento-mirror,代码行数:26,代码来源:Option.php

示例7: _getProducts

 protected function _getProducts($productIds = null, $storeId, $entityId = 0, &$lastEntityId)
 {
     $products = array();
     $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
     if (!is_null($productIds)) {
         if (!is_array($productIds)) {
             $productIds = array($productIds);
         }
     }
     $select = $this->_getWriteAdapter()->select()->useStraightJoin(true)->from(array('e' => $this->getTable('catalog/product')), array('entity_id'))->join(array('w' => $this->getTable('catalog/product_website')), $this->_getWriteAdapter()->quoteInto('e.entity_id=w.product_id AND w.website_id=?', $websiteId), array())->where('e.entity_id>?', $entityId)->order('e.entity_id')->limit($this->_productLimit);
     if (!is_null($productIds)) {
         $select->where('e.entity_id IN(?)', $productIds);
     }
     $query = $this->_getWriteAdapter()->query($select);
     while ($row = $query->fetch()) {
         $product = new Varien_Object($row);
         $product->setIdFieldName('entity_id');
         $product->setCategoryIds(array());
         $product->setStoreId($storeId);
         $products[$product->getId()] = $product;
         $lastEntityId = $product->getId();
     }
     unset($query);
     if ($products) {
         $select = $this->_getReadAdapter()->select()->from($this->getTable('catalog/category_product'), array('product_id', 'category_id'))->where('product_id IN(?)', array_keys($products));
         $categories = $this->_getReadAdapter()->fetchAll($select);
         foreach ($categories as $category) {
             $productId = $category['product_id'];
             $categoryIds = $products[$productId]->getCategoryIds();
             $categoryIds[] = $category['category_id'];
             $products[$productId]->setCategoryIds($categoryIds);
         }
         foreach (array('name', 'url_key', 'url_path', 'visibility', "status") as $attributeCode) {
             $attributes = $this->_getProductAttribute($attributeCode, array_keys($products), $storeId);
             foreach ($attributes as $productId => $attributeValue) {
                 $products[$productId]->setData($attributeCode, $attributeValue);
             }
         }
     }
     return $products;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:41,代码来源:Url.php

示例8: _getCategories

 protected function _getCategories($categoryIds, $storeId = null, $path = null)
 {
     $isActiveAttribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_category', 'is_active');
     $categories = array();
     if (!is_array($categoryIds)) {
         $categoryIds = array($categoryIds);
     }
     $select = $this->_getWriteAdapter()->select()->from(array('main_table' => $this->getTable('catalog/category')), array('main_table.entity_id', 'main_table.parent_id', 'is_active' => 'IFNULL(c.value, d.value)', 'main_table.path'));
     if (is_null($path)) {
         $select->where('main_table.entity_id IN(?)', $categoryIds);
     } else {
         $select->where('main_table.path LIKE ?', $path . '%')->order('main_table.path');
     }
     $table = $this->getTable('catalog/category') . '_int';
     $select->joinLeft(array('d' => $table), "d.attribute_id = '{$isActiveAttribute->getId()}' AND d.store_id = 0 AND d.entity_id = main_table.entity_id", array())->joinLeft(array('c' => $table), "c.attribute_id = '{$isActiveAttribute->getId()}' AND c.store_id = '{$storeId}' AND c.entity_id = main_table.entity_id", array());
     if (!is_null($storeId)) {
         $rootCategoryPath = $this->getStores($storeId)->getRootCategoryPath();
         $rootCategoryPathLength = strlen($rootCategoryPath);
     }
     $rowSet = $this->_getWriteAdapter()->fetchAll($select);
     foreach ($rowSet as $row) {
         if (!is_null($storeId) && substr($row['path'], 0, $rootCategoryPathLength) != $rootCategoryPath) {
             continue;
         }
         $category = new Varien_Object($row);
         $category->setIdFieldName('entity_id');
         $category->setStoreId($storeId);
         $this->_prepareCategoryParentId($category);
         $categories[$category->getId()] = $category;
     }
     unset($rowSet);
     if (!is_null($storeId) && $categories) {
         foreach (array('name', 'url_key', 'url_path') as $attributeCode) {
             $attributes = $this->_getCategoryAttribute($attributeCode, array_keys($categories), $category->getStoreId());
             foreach ($attributes as $categoryId => $attributeValue) {
                 $categories[$categoryId]->setData($attributeCode, $attributeValue);
             }
         }
     }
     return $categories;
 }
开发者ID:rlucia,项目名称:magento-oscom-migration-tool,代码行数:41,代码来源:Url.php

示例9: previewAction

 public function previewAction()
 {
     $data = $this->getRequest()->getParams();
     $product = Mage::getModel('catalog/product')->load($data['product']);
     if (Mage::helper('giftcards')->isUseDefaultPicture() || !$product->getId()) {
         $picture = Mage::getDesign()->getSkinUrl('images/giftcard.png', array('_area' => 'frontend'));
     } else {
         if ($product->getId() && $product->getImage() != 'no_selection') {
             $picture = Mage::helper('catalog/image')->init($product, 'image');
         } else {
             $picture = Mage::getDesign()->getSkinUrl('images/giftcard.png', array('_area' => 'frontend'));
         }
     }
     $currencySymbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
     if ($currencySymbol == '€') {
         $currencySymbol = '€';
     } elseif ($currencySymbol == '£') {
         $currencySymbol = '£';
     }
     $storeId = Mage::app()->getStore()->getId();
     $post = array('amount' => $currencySymbol . $data['price'], 'code' => 'XXXX-XXXX-XXXX', 'email-to' => $data['mail-to'], 'email-from' => $data['mail-from'], 'link' => '#', 'email-message' => $data['mail-message'], 'store-phone' => Mage::getStoreConfig('general/store_information/phone'), 'picture' => $picture);
     $mailTemplate = Mage::getModel('core/email_template');
     $postObject = new Varien_Object();
     $postObject->setData($post);
     $postObject->setStoreId($storeId);
     if ($data['card-type'] == 'email') {
         $template = 'giftcards/email/email_template';
     } elseif ($data['card-type'] == 'print') {
         $template = 'giftcards/email/print_template';
     }
     $mailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))->sendTransactional(Mage::getStoreConfig($template), 'general', '', null, array('data' => $postObject));
     //$emailTemplate  = Mage::getModel('core/email_template')->loadDefault('giftcards_email_email_template');
     $mail = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
     $mail .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2) . '" lang="' . substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2) . '">';
     $mail .= $mailTemplate->getProcessedTemplate();
     $mail .= '</html>';
     echo $mail;
     exit;
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:39,代码来源:PreviewController.php

示例10: _prepareCollection

 /**
  * Prepare grid collection
  */
 protected function _prepareCollection()
 {
     $collection = new Varien_Data_Collection();
     $cache = Mage::helper('varnish')->getRedisCache()->getFrontend();
     $ids = $cache->getIdsMatchingTags(array('VARNISH-CACHETYPE-PER-PAGE'));
     foreach ($ids as $id) {
         $data = unserialize($cache->load($id));
         $item = new Varien_Object();
         $item->setId($id);
         $item->setStoreId($data->getStoreId());
         $item->setParentUrl($data->getParentUrl());
         $item->setBlockName($data->getNameInLayout());
         $item->setFingerprint($id);
         $item->setProbeUrl($data->getUrl());
         $collection->addItem($item);
     }
     $this->setCollection($collection);
     $sort = $this->getParam($this->getVarNameSort()) ? $this->getParam($this->getVarNameSort()) : $this->getDefaultSort();
     $dir = $this->getParam($this->getVarNameDir()) ? $this->getParam($this->getVarNameDir()) : $this->getDefaultDir();
     $this->_sortCollectionBy($sort, $dir);
     return parent::_prepareCollection();
 }
开发者ID:mwin007,项目名称:Magento-Varnish,代码行数:25,代码来源:Grid.php

示例11: _getProducts

 /**
  * Retrieve Product data objects
  * LOE: remove if status(=2) is disabled or visibility(=1) false
  *
  * @param int|array $productIds
  * @param int $storeId
  * @param int $entityId
  * @param int $lastEntityId
  * @return array
  */
 protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId)
 {
     $products = array();
     $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
     $adapter = $this->_getReadAdapter();
     if ($productIds !== null) {
         if (!is_array($productIds)) {
             $productIds = array($productIds);
         }
     }
     $bind = array('website_id' => (int) $websiteId, 'entity_id' => (int) $entityId);
     $select = $adapter->select()->useStraightJoin(true)->from(array('e' => $this->getTable('catalog/product')), array('entity_id'))->join(array('w' => $this->getTable('catalog/product_website')), 'e.entity_id = w.product_id AND w.website_id = :website_id', array())->where('e.entity_id > :entity_id')->order('e.entity_id')->limit($this->_productLimit);
     if ($productIds !== null) {
         $select->where('e.entity_id IN(?)', $productIds);
     }
     //if we are to ignore disabled products... add the necessary joins and conditions
     if ($this->_helper()->HideDisabledProducts($storeId)) {
         $statusCode = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product', 'status');
         $bind['status_id'] = (int) $statusCode;
         $bind['disabled'] = Mage_Catalog_Model_Product_Status::STATUS_DISABLED;
         $bind['store_id'] = (int) $storeId;
         $bind['default_store_id'] = 0;
         $select->joinLeft(array('s' => $this->getTable(array('catalog/product', 'int'))), 'e.entity_id = s.entity_id AND s.attribute_id = :status_id AND s.store_id = :store_id', array());
         $select->joinLeft(array('ds' => $this->getTable(array('catalog/product', 'int'))), 'e.entity_id = ds.entity_id AND ds.attribute_id = :status_id AND ds.store_id = :default_store_id', array());
         $select->where('s.value <> :disabled OR (s.value IS NULL AND ds.value <> :disabled)');
     }
     //if we are to ignore not visible products... add the necessary joins and conditions
     if ($this->_helper()->HideNotVisibileProducts($storeId)) {
         $visibilityCode = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product', 'visibility');
         $bind['not_visible'] = Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE;
         $bind['visibility_id'] = (int) $visibilityCode;
         $bind['store_id'] = (int) $storeId;
         $bind['default_store_id'] = 0;
         $select->joinLeft(array('v' => $this->getTable(array('catalog/product', 'int'))), 'e.entity_id = v.entity_id AND v.attribute_id = :visibility_id AND v.store_id = :store_id', array());
         $select->joinLeft(array('dv' => $this->getTable(array('catalog/product', 'int'))), 'e.entity_id = dv.entity_id AND dv.attribute_id = :visibility_id AND dv.store_id = :default_store_id', array());
         $select->where('v.value <> :not_visible OR (v.value IS NULL AND dv.value <> :not_visible)');
     }
     $rowSet = $adapter->fetchAll($select, $bind);
     foreach ($rowSet as $row) {
         $product = new Varien_Object($row);
         $product->setIdFieldName('entity_id');
         $product->setCategoryIds(array());
         $product->setStoreId($storeId);
         $products[$product->getId()] = $product;
         $lastEntityId = $product->getId();
     }
     unset($rowSet);
     if ($products) {
         $select = $adapter->select()->from($this->getTable('catalog/category_product'), array('product_id', 'category_id'))->where('product_id IN(?)', array_keys($products));
         $categories = $adapter->fetchAll($select);
         foreach ($categories as $category) {
             $productId = $category['product_id'];
             $categoryIds = $products[$productId]->getCategoryIds();
             $categoryIds[] = $category['category_id'];
             $products[$productId]->setCategoryIds($categoryIds);
         }
         foreach (array('name', 'url_key', 'url_path') as $attributeCode) {
             $attributes = $this->_getProductAttribute($attributeCode, array_keys($products), $storeId);
             foreach ($attributes as $productId => $attributeValue) {
                 $products[$productId]->setData($attributeCode, $attributeValue);
             }
         }
     }
     return $products;
 }
开发者ID:ergontech,项目名称:Loewenstark_UrlIndexer,代码行数:75,代码来源:Url.php

示例12: registerGuestCustomer

 /**
  * Register on Magento's registry GUEST customer data for MergeVars for on checkout subscribe
  *
  * @param Mage_Sales_Model_Order $order
  * @return void
  */
 public function registerGuestCustomer($order)
 {
     if (Mage::registry('mc_guest_customer')) {
         return;
     }
     $customer = new Varien_Object();
     $customer->setId('guest' . time());
     $customer->setEmail($order->getBillingAddress()->getEmail());
     $customer->setStoreId($order->getStoreId());
     $customer->setFirstname($order->getBillingAddress()->getFirstname());
     $customer->setLastname($order->getBillingAddress()->getLastname());
     $customer->setPrimaryBillingAddress($order->getBillingAddress());
     $customer->setPrimaryShippingAddress($order->getShippingAddress());
     Mage::register('mc_guest_customer', $customer, TRUE);
 }
开发者ID:kirchbergerknorr,项目名称:magemonkey,代码行数:21,代码来源:Data.php

示例13: setRequest

 /**
  * Prepare and set request in property of current instance
  *
  * @param Varien_Object $request
  * @return Mage_Usa_Model_Shipping_Carrier_Dhl
  */
 public function setRequest(Varien_Object $request)
 {
     $this->_request = $request;
     $this->setStore($request->getStoreId());
     $requestObject = new Varien_Object();
     $requestObject->setIsGenerateLabelReturn($request->getIsGenerateLabelReturn());
     $requestObject->setStoreId($request->getStoreId());
     if ($request->getLimitMethod()) {
         $requestObject->setService($request->getLimitMethod());
     }
     $requestObject = $this->_addParams($requestObject);
     if ($request->getDestPostcode()) {
         $requestObject->setDestPostal($request->getDestPostcode());
     }
     $requestObject->setOrigCountry($this->_getDefaultValue($request->getOrigCountry(), Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID))->setOrigCountryId($this->_getDefaultValue($request->getOrigCountryId(), Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID));
     $shippingWeight = $request->getPackageWeight();
     $requestObject->setValue(round($request->getPackageValue(), 2))->setValueWithDiscount($request->getPackageValueWithDiscount())->setCustomsValue($request->getPackageCustomsValue())->setDestStreet(Mage::helper('core/string')->substr(str_replace("\n", '', $request->getDestStreet()), 0, 35))->setDestStreetLine2($request->getDestStreetLine2())->setDestCity($request->getDestCity())->setOrigCompanyName($request->getOrigCompanyName())->setOrigCity($request->getOrigCity())->setOrigPhoneNumber($request->getOrigPhoneNumber())->setOrigPersonName($request->getOrigPersonName())->setOrigEmail(Mage::getStoreConfig('trans_email/ident_general/email', $requestObject->getStoreId()))->setOrigCity($request->getOrigCity())->setOrigPostal($request->getOrigPostal())->setOrigStreetLine2($request->getOrigStreetLine2())->setDestPhoneNumber($request->getDestPhoneNumber())->setDestPersonName($request->getDestPersonName())->setDestCompanyName($request->getDestCompanyName());
     $originStreet2 = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ADDRESS2, $requestObject->getStoreId());
     $requestObject->setOrigStreet($request->getOrigStreet() ? $request->getOrigStreet() : $originStreet2);
     if (is_numeric($request->getOrigState())) {
         $requestObject->setOrigState(Mage::getModel('directory/region')->load($request->getOrigState())->getCode());
     } else {
         $requestObject->setOrigState($request->getOrigState());
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     // for DHL, Puerto Rico state for US will assume as Puerto Rico country
     // for Puerto Rico, dhl will ship as international
     if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID)) {
         $destCountry = self::PUERTORICO_COUNTRY_ID;
     }
     $requestObject->setDestCountryId($destCountry)->setDestState($request->getDestRegionCode())->setWeight($shippingWeight)->setFreeMethodWeight($request->getFreeMethodWeight())->setOrderShipment($request->getOrderShipment());
     if ($request->getPackageId()) {
         $requestObject->setPackageId($request->getPackageId());
     }
     $requestObject->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax());
     $this->_rawRequest = $requestObject;
     return $this;
 }
开发者ID:okite11,项目名称:frames21,代码行数:48,代码来源:International.php

示例14: _prepareLayout

 protected function _prepareLayout()
 {
     $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
     $modelName = Mage::helper('amshopby')->isVersionLessThan(1, 4) ? 'catalog/entity_attribute' : 'catalog/resource_eav_attribute';
     $attribute = Mage::getModel($modelName)->loadByCode($entityTypeId, $this->getAttributeCode());
     if (!$attribute->getId()) {
         return parent::_prepareLayout();
     }
     //1.3 only
     if (!$attribute->getSourceModel()) {
         $attribute->setSourceModel('eav/entity_attribute_source_table');
     }
     $options = $attribute->getFrontend()->getSelectOptions();
     array_shift($options);
     $filter = new Varien_Object();
     // important when used at category pages
     $layer = Mage::getModel('catalog/layer')->setCurrentCategory(Mage::app()->getStore()->getRootCategoryId());
     $filter->setLayer($layer);
     $filter->setStoreId(Mage::app()->getStore()->getId());
     $filter->setAttributeModel($attribute);
     $optionsCount = array();
     if (Mage::helper('amshopby')->isVersionLessThan(1, 4)) {
         $category = Mage::getModel('catalog/category')->load(Mage::app()->getStore()->getRootCategoryId());
         $collection = $category->getProductCollection();
         Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
         Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
         $optionsCount = Mage::getSingleton('catalogindex/attribute')->getCount($attribute, $collection->getSelect());
     } else {
         $optionsCount = Mage::getResourceModel('catalog/layer_filter_attribute')->getCount($filter);
     }
     usort($options, array($this, '_sortByName'));
     // add images
     $ids = array();
     foreach ($options as $opt) {
         $ids[] = $opt['value'];
     }
     $collection = Mage::getResourceModel('amshopby/value_collection')->addFieldToFilter('option_id', array('in' => $ids))->load();
     $images = array();
     foreach ($collection as $value) {
         $images[$value->getOptionId()] = $value->getImgBig() ? Mage::getBaseUrl('media') . 'amshopby/' . $value->getImgBig() : '';
     }
     // end add images
     $c = 0;
     $letters = array();
     $hlp = Mage::helper('amshopby/url');
     foreach ($options as $opt) {
         if (!empty($optionsCount[$opt['value']])) {
             $opt['cnt'] = $optionsCount[$opt['value']];
             $opt['url'] = $hlp->getOptionUrl($attribute->getAttributeCode(), $opt['label'], $opt['value']);
             $opt['img'] = isset($images[$opt['value']]) ? $images[$opt['value']] : '';
             //$i = mb_strtoupper(mb_substr($opt['label'], 0, 1, 'UTF-8'));
             $i = strtoupper(substr($opt['label'], 0, 1));
             if (!isset($letters[$i]['items'])) {
                 $letters[$i]['items'] = array();
             }
             $letters[$i]['items'][] = $opt;
             if (!isset($letters[$i]['count'])) {
                 $letters[$i]['count'] = 0;
             }
             $letters[$i]['count']++;
             ++$c;
         }
     }
     if (!$letters) {
         return parent::_prepareLayout();
     }
     $itemsPerColumn = ceil(($c + sizeof($letters)) / max(1, abs(intVal($this->getColumns()))));
     $col = 0;
     // current column
     $num = 0;
     // current number of items in column
     foreach ($letters as $letter => $items) {
         $this->items[$col][$letter] = $items['items'];
         $num += $items['count'];
         $num++;
         if ($num >= $itemsPerColumn) {
             $num = 0;
             $col++;
         }
     }
     return parent::_prepareLayout();
 }
开发者ID:nilshopsahl,项目名称:hasla.local,代码行数:82,代码来源:List.php

示例15: _prepareLayout

 protected function _prepareLayout()
 {
     $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
     /** @var Mage_Eav_Model_Attribute $attribute */
     $attribute = Mage::getModel('catalog/resource_eav_attribute')->loadByCode($entityTypeId, $this->getAttributeCode());
     if (!$attribute->getId()) {
         return parent::_prepareLayout();
     }
     $options = $attribute->getFrontend()->getSelectOptions();
     array_shift($options);
     $filter = new Varien_Object();
     // important when used at category pages
     $layer = Mage::getModel('catalog/layer')->setCurrentCategory(Mage::app()->getStore()->getRootCategoryId());
     $filter->setLayer($layer);
     $filter->setStoreId(Mage::app()->getStore()->getId());
     $filter->setAttributeModel($attribute);
     $optionsCount = Mage::getResourceModel('catalog/layer_filter_attribute')->getCount($filter);
     usort($options, array($this, '_sortByName'));
     $images = Mage::getStoreConfig('amshopby/brands/show_images') ? $this->_getOptionImages($options) : null;
     /** @var Amasty_Shopby_Helper_Url $urlHelper */
     $urlHelper = Mage::helper('amshopby/url');
     $c = 0;
     $letters = array();
     foreach ($options as $opt) {
         if (!empty($optionsCount[$opt['value']])) {
             $opt['cnt'] = $optionsCount[$opt['value']];
             $opt['url'] = $urlHelper->getOptionUrl($attribute->getAttributeCode(), $opt['value']);
             $opt['img'] = $images ? $images[$opt['value']] : null;
             if (function_exists('mb_strtoupper')) {
                 $i = mb_strtoupper(mb_substr($opt['label'], 0, 1, 'UTF-8'));
             } else {
                 $i = strtoupper(substr($opt['label'], 0, 1));
             }
             if (is_numeric($i)) {
                 $i = '#';
             }
             if (!isset($letters[$i]['items'])) {
                 $letters[$i]['items'] = array();
             }
             $letters[$i]['items'][] = $opt;
             if (!isset($letters[$i]['count'])) {
                 $letters[$i]['count'] = 0;
             }
             $letters[$i]['count']++;
             ++$c;
         }
     }
     if (!$letters) {
         return parent::_prepareLayout();
     }
     $itemsPerColumn = ceil(($c + sizeof($letters)) / max(1, abs(intVal($this->getColumns()))));
     $col = 0;
     // current column
     $num = 0;
     // current number of items in column
     foreach ($letters as $letter => $items) {
         $this->items[$col][$letter] = $items['items'];
         $num += $items['count'];
         $num++;
         if ($num >= $itemsPerColumn) {
             $num = 0;
             $col++;
         }
     }
     return parent::_prepareLayout();
 }
开发者ID:xiaoguizhidao,项目名称:tyler-live,代码行数:66,代码来源:List.php


注:本文中的Varien_Object::setStoreId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。