两个商店都有不同的根类别.Main Store是默认的样本数据,Second Store只有一个我添加的产品.我原以为使用商店过滤器,只会显示当前商店根类别中的产品.但我正在展示每一件产品.我通过在类别视图模板中放置以下内容来测试它:
$store_id = Mage::app()->getStore()->getId();
$_testproductCollection = Mage::getResourceModel('reports/product_collection')
->setStoreId($storeId)
->addStoreFilter($store_id)
->addAttributeToSelect('*');
$_testproductCollection->load();
foreach($_testproductCollection as $_testproduct){
echo $this->htmlEscape($_testproduct->getName());
};
Run Code Online (Sandbox Code Playgroud)
如果我打印商店ID,它会给我正确的号码.我在第二个商店只有一个产品,为什么我要从所有商店回收所有产品?我可以将主商店中的每个产品设置为不在Store2中显示,然后添加可见性过滤器,但这将需要永远.
另外,我刚注意到,如果我回应产品商店ID,我会得到当前ID,而不是它分配给的商店:
echo $_testproduct->getStoreId()
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
我在ZEND中编写了代码,用于访问Magento REST API以访问数据.
<?php
require_once 'Zend/Oauth/Consumer.php';
class AuthController extends Zend_Controller_Action
{
public function init()
{
$this->hostname = 'http://localhost/magento';
$consumerKey = 'mkkzxuu1bkveejyzjam5hl2pzaxxepwv';
$consumerSecret = 'bcmczrp3ofn9vmviqu3j8o1ioa7fisl6';
$callbackUrl = 'http://localhost/magento/oauth/token';
$this->config = array(
'callbackUrl' => $callbackUrl,
'requestTokenUrl' => $this->hostname . '/oauth/initiate',
'siteUrl' => $this->hostname . '/oauth',
'consumerKey' => $consumerKey,
'consumerSecret' => $consumerSecret,
'authorizeUrl' => $this->hostname . '/admin/oauth_authorize',
// 'authorizeUrl' => $this->hostname . '/oauth/authorize',
'accessTokenUrl' => $this->hostname . '/oauth/token'
);
}
public function indexAction()
{
$accesssession = new Zend_Session_Namespace('AccessToken');
if (isset($accesssession->accessToken)) {
$token = …Run Code Online (Sandbox Code Playgroud) 当我尝试在客户/客户模型对象中使用get Entity Id(getEntityId())方法时,我收到错误.
请检查我的波纹管代码.
我想用贝娄的代码.但它显示错误.
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail('email@example.com'); //load customer by email id
Run Code Online (Sandbox Code Playgroud)
而bellow的代码工作正常.使用getEntityId()
$id=3;
$customer = Mage::getModel('customer/customer')->load($id);
Run Code Online (Sandbox Code Playgroud)
所以请为loadByEmail()方法提供解决方案.
我想使用Magento中的Sales/Order对象获取网站ID.
我试过下面的代码.但它没有用.
$order = Mage::getModel('sales/order')->getCollection();
foreach($order as $o){
//Here i want to get store id and website id
echo $o->getStoreName();
echo $o->getStoreId();
echo $o->getWebsiteId();
}
Run Code Online (Sandbox Code Playgroud)
商店ID按预期工作.但网站ID报告为null.
请建议任何其他方式,这是有效的.