本文整理汇总了PHP中Mage_Catalog_Model_Product::getEntityId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getEntityId方法的具体用法?PHP Mage_Catalog_Model_Product::getEntityId怎么用?PHP Mage_Catalog_Model_Product::getEntityId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product::getEntityId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(array $args)
{
$this->_product = $args['product'];
$this->_store = $args['store'];
$this->_coreHelper = $args['core'];
$this->_weeeHelper = $args['weee'];
$this->_taxHelper = $args['tax'];
$this->_product = Mage::getModel("catalog/product")->getCollection()->addAttributeToSelect(Mage::getSingleton("catalog/config")->getProductAttributes())->addAttributeToFilter("entity_id", $this->_product->getEntityId())->setPage(1, 1)->addMinimalPrice()->addFinalPrice()->addTaxPercents()->load()->getFirstItem();
$this->_simplePricesTax = $this->_taxHelper->displayPriceIncludingTax() || $this->_taxHelper->displayBothPrices();
$this->_minimalPriceValue = $this->_product->getMinimalPrice();
$this->_minimalPrice = $this->_taxHelper->getPrice($this->_product, $this->_minimalPriceValue, $this->_simplePricesTax);
$this->_setPrices();
}
示例2: getAddUrl
/**
* Retrieve url for add product to cart
*
* @param Mage_Catalog_Model_Product $product
* @return string
*/
public function getAddUrl($product, $additional = array())
{
$continueUrl = Mage::helper('core')->urlEncode($this->getCurrentUrl());
$urlParamName = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED;
$routeParams = array(
$urlParamName => $continueUrl,
'product' => $product->getEntityId()
);
if (!empty($additional)) {
$routeParams = array_merge($routeParams, $additional);
}
if ($product->hasUrlDataObject()) {
$routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
$routeParams['_store_to_url'] = true;
}
if ($this->_getRequest()->getRouteName() == 'checkout'
&& $this->_getRequest()->getControllerName() == 'cart') {
$routeParams['in_cart'] = 1;
}
return $this->_getUrl('checkout/cart/add', $routeParams);
}
示例3: _createProduct
/**
* @param Mage_Catalog_Model_Product $product
* @return array
*/
protected function _createProduct(Mage_Catalog_Model_Product $product)
{
$brand = null;
if ($product->hasData('brand')) {
$brand = $product->getAttributeText('brand');
}
$manufacturer = null;
if ($product->hasData('manufacturer')) {
$manufacturer = $product->getAttributeText('manufacturer');
}
$data = array('id' => $product->getEntityId(), 'productTypeId' => $this->_getProductTypeId($product), 'name' => array($this->_createLocalizedValue($product->getName())), 'shortDescription' => array($this->_createLocalizedValue($product->getShortDescription())), 'description' => array($this->_createLocalizedValue($product->getDescription())), 'GTIN' => $product->hasData('gtin') ? $product->getAttributeText('gtin') : null, 'brand' => !empty($brand) ? array($this->_createLocalizedValue($brand)) : null, 'manufacturer' => !empty($manufacturer) ? array($this->_createLocalizedValue($manufacturer)) : null, 'MPN' => $product->hasData('mpn') ? $product->getAttributeText('mpn') : null, 'MSRP' => $this->_getMsrp($product), 'MAP' => $product->hasData('map') ? $this->_getCurrencyAmount($product->getAttributeText('map')) : null, 'images' => $this->_createImageUrls($product), 'attributes' => $this->_createAttributes($product), 'variationFactors' => $this->_createVariationFactors($product), 'skuList' => $this->_createSkus($product));
return $data;
}
示例4: getAddUrl
/**
* Retrieve url for add product to cart
*
* @param Mage_Catalog_Model_Product $product
* @param array $additional
* @return string
*/
public function getAddUrl($product, $additional = array())
{
$routeParams = array(Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')->urlEncode($this->getCurrentUrl()), 'product' => $product->getEntityId(), Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey());
if (!empty($additional)) {
$routeParams = array_merge($routeParams, $additional);
}
if ($product->hasUrlDataObject()) {
$routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
$routeParams['_store_to_url'] = true;
}
if ($this->_getRequest()->getRouteName() == 'checkout' && $this->_getRequest()->getControllerName() == 'cart') {
$routeParams['in_cart'] = 1;
}
return $this->_getUrl('checkout/cart/add', $routeParams);
}
示例5: getAddUrlWithParams
/**
* Retrieve url for adding product to wishlist with params
*
* @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item
* @param array $params
*
* @return string|bool
*/
public function getAddUrlWithParams($item, array $params = array())
{
$productId = null;
if ($item instanceof Mage_Catalog_Model_Product) {
$productId = $item->getEntityId();
}
if ($item instanceof Mage_Wishlist_Model_Item) {
$productId = $item->getProductId();
}
if ($productId) {
$params['product'] = $productId;
$params[Mage_Core_Model_Url::FORM_KEY] = $this->_getSingletonModel('core/session')->getFormKey();
return $this->_getUrlStore($item)->getUrl('wishlist/index/add', $params);
}
return false;
}
示例6: _getNameSuggestFieldArray
/**
* @param Mage_Catalog_Model_Product $product
* @param array $input
* @param $weight
* @return array
*/
protected function _getNameSuggestFieldArray(Mage_Catalog_Model_Product $product, array $input, $weight)
{
return array("input" => $input, "output" => $product->getName(), "weight" => (int) $weight, "payload" => array("id" => $product->getEntityId(), "path" => $this->_getProductUrlPath($product)));
}
示例7: getUrl
/**
* Retrieve Product URL using UrlDataObject
*
* @param Mage_Catalog_Model_Product $product
* @param array $params
* @return string
*/
public function getUrl(Mage_Catalog_Model_Product $product, $params = array())
{
$routePath = '';
$routeParams = $params;
$storeId = $product->getStoreId();
if (isset($params['_ignore_category'])) {
unset($params['_ignore_category']);
$categoryId = null;
} else {
$categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId() ? $product->getCategoryId() : null;
}
if ($product->hasUrlDataObject()) {
$requestPath = $product->getUrlDataObject()->getUrlRewrite();
$routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
} else {
$requestPath = $product->getRequestPath();
if (empty($requestPath) && $requestPath !== false) {
$idPath = sprintf('product/%d', $product->getEntityId());
if ($categoryId) {
$idPath = sprintf('%s/%d', $idPath, $categoryId);
}
$rewrite = $this->getUrlRewrite();
$rewrite->setStoreId($storeId)->loadByIdPath($idPath);
if ($rewrite->getId()) {
$requestPath = $rewrite->getRequestPath();
$product->setRequestPath($requestPath);
} else {
$product->setRequestPath(false);
}
}
}
if (isset($routeParams['_store'])) {
$storeId = Mage::app()->getStore($routeParams['_store'])->getId();
}
if ($storeId != Mage::app()->getStore()->getId()) {
$routeParams['_store_to_url'] = true;
}
if (!empty($requestPath)) {
$routeParams['_direct'] = $requestPath;
} else {
$routePath = 'catalog/product/view';
$routeParams['id'] = $product->getId();
$routeParams['s'] = $product->getUrlKey();
if ($categoryId) {
$routeParams['category'] = $categoryId;
}
}
// reset cached URL instance GET query params
if (!isset($routeParams['_query'])) {
$routeParams['_query'] = array();
}
return $this->getUrlInstance()->setStore($storeId)->getUrl($routePath, $routeParams);
}
示例8: getAvailableInCategories
/**
* Retrieve category ids where product is available
*
* @param Mage_Catalog_Model_Product $object
* @return array
*/
public function getAvailableInCategories($object)
{
// is_parent=1 ensures that we'll get only category IDs those are direct parents of the product, instead of
// fetching all parent IDs, including those are higher on the tree
$select = $this->_getReadAdapter()->select()->distinct()->from($this->getTable('catalog/category_product_index'), array('category_id'))->where('product_id = ? AND is_parent = 1', (int) $object->getEntityId());
return $this->_getReadAdapter()->fetchCol($select);
}
示例9: getAvailableInCategories
/**
* Retrieve category ids where product is available
*
* @param Mage_Catalog_Model_Product $object
* @return array
*/
public function getAvailableInCategories($object)
{
$select = $this->_getReadAdapter()->select()->from($this->getTable('catalog/category_product_index'), array('category_id'))->where('product_id = ?', (int) $object->getEntityId());
return $this->_getReadAdapter()->fetchCol($select);
}
示例10: _getRequestPath
/**
* Retrieve request path
*
* @param Mage_Catalog_Model_Product $product
* @param int $categoryId
* @return bool|string
*/
protected function _getRequestPath($product, $categoryId)
{
$idPath = sprintf('product/%d', $product->getEntityId());
if ($categoryId) {
$idPath = sprintf('%s/%d', $idPath, $categoryId);
}
$rewrite = $this->getUrlRewrite();
$rewrite->setStoreId($product->getStoreId())->loadByIdPath($idPath);
if ($rewrite->getId()) {
return $rewrite->getRequestPath();
}
return false;
}
示例11: _getParentProduct
private function _getParentProduct(Mage_Catalog_Model_Product $product)
{
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getEntityId());
if (is_array($parentIds) && count($parentIds) > 0) {
$parentId = $parentIds[0];
if ($parentId != null) {
if (!array_key_exists($parentId, $this->_parentsById)) {
$this->_parentsById[$parentId] = Mage::getModel('catalog/product')->load($parentId);
}
return $this->_parentsById[$parentId];
}
}
return null;
}
示例12: getCategoryIdsWithAnchors
/**
* Retrieve product categories
*
* @param Mage_Catalog_Model_Product $object
* @return array
*/
public function getCategoryIdsWithAnchors($object)
{
$selectRootCategories = $this->_getReadAdapter()->select()->from(array($this->getTable('catalog/category')), array('entity_id'))->where('level <= 1');
$rootIds = $this->_getReadAdapter()->fetchCol($selectRootCategories);
$select = $this->_getReadAdapter()->select()->from(array($this->getTable('catalog/category_product_index')), array('category_id'))->where('product_id = ?', (int) $object->getEntityId())->where('category_id NOT IN(?)', $rootIds);
return $this->_getReadAdapter()->fetchCol($select);
}
示例13: _generateProductCacheTags
/**
* Accommodated grouped products by adding the tag for each associated product.
* @param Varien_Event_Observer $observer
* @param Mage_Catalog_Model_Product $oProduct
* @return array
*/
private function _generateProductCacheTags(Varien_Event_Observer $observer, $oProduct)
{
if (!$oProduct) {
return array();
}
$tags = array(Mage_Core_Block_Abstract::CACHE_GROUP, Mage_Core_Model_App::CACHE_TAG, Mage_Core_Model_Store::CACHE_TAG, Mage_Catalog_Model_Product::CACHE_TAG . '_' . $oProduct->getEntityId());
if ($oProduct->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_GROUPED) {
$aChildren = $oProduct->getTypeInstance(true)->getAssociatedProducts($oProduct);
foreach ($aChildren as $oChild) {
$tags[] = Mage_Catalog_Model_Product::CACHE_TAG . '_' . $oChild->getEntityId();
}
}
return $tags;
}
示例14: getAddUrlWithParams
/**
* Retrieve url for adding product to wishlist with params
*
* @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item
* @param array $params
*
* @return string|bool
*/
public function getAddUrlWithParams($item, array $params = array())
{
$productId = null;
if ($item instanceof Mage_Catalog_Model_Product) {
$productId = $item->getEntityId();
}
if ($item instanceof Mage_Wishlist_Model_Item) {
$productId = $item->getProductId();
}
if ($productId) {
$params['product'] = $productId;
return $this->_getUrlStore($item)->getUrl('wishlist/index/add', $params);
}
return false;
}
示例15: _sendOfferMessages
protected function _sendOfferMessages(Mage_Catalog_Model_Product $product, $performThoroughCheck = false)
{
if ($this->_isValueRegistered('xcom_offer_messages_sent', $product->getId())) {
return;
}
$this->_registerValue('xcom_offer_messages_sent', $product->getId());
$cancelledSids = array();
$createdSids = array();
if ($performThoroughCheck || $product->getIsChangedWebsites()) {
$oldWids = $this->_getRegisterValueForKey('xcom_offer_old_stores', $product->getId());
if (!isset($oldWids)) {
$oldWids = array();
}
$cancelledSids = array_diff($oldWids, $product->getStoreIds());
$createdSids = array_diff($product->getStoreIds(), $oldWids);
}
$updatedSids = array_diff($product->getStoreIds(), $cancelledSids, $createdSids);
// There is a case where product was duplicated and just now a sku was filled in
if ($product->getOrigData()) {
$oldSku = $product->getOrigData('sku');
$sku = $product->getSku();
if (empty($oldSku) && !empty($sku)) {
$createdSids = array_merge($createdSids, $updatedSids);
$updatedSids = array();
}
}
if ($product->dataHasChangedFor('price')) {
foreach ($updatedSids as $sid) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferUpdate/WebStoreOfferPriceUpdated', $offerInputData);
}
}
if ($this->_isValueRegistered('xcom_inventory_updated', $product->getId())) {
foreach ($updatedSids as $sid) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferUpdate/WebStoreOfferQuantityUpdated', $offerInputData);
}
}
if ($product->dataHasChangedFor('visibility') || $product->dataHasChangedFor('status')) {
foreach ($updatedSids as $sid) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferUpdate/WebStoreOfferUpdated', $offerInputData);
}
}
if ($product->dataHasChangedFor('url_key')) {
foreach ($updatedSids as $sid) {
Mage::getModel('xcom_chronicle/product_url_update')->setProductId($product->getEntityId())->setStoreId($sid)->setUrlPath($product->getUrlPath())->save();
}
}
foreach ($createdSids as $sid) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferCreation/WebStoreOfferCreated', $offerInputData);
}
foreach ($cancelledSids as $sid) {
$storeProduct = $this->_getRegisterValueForKey('xcom_offer_old_stores_products', $product->getId() . '_' . $sid);
if (empty($storeProduct)) {
$offerInputData = array('product' => $product, 'store_id' => $sid);
} else {
$offerInputData = array('product' => $storeProduct);
}
Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferDeletion/WebStoreOfferDeleted', $offerInputData);
}
}