Magento不替换已存储的物品 [英] Magento not displaing stored articles

查看:91
本文介绍了Magento不替换已存储的物品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在来自外部源的magento创建了一个脚本以存储物品.

I created a script to store articles in magento from external sources.

这是我目前正在做的

    $this->product = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->artnr);
    Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
    if($this->product===false || $this->product->getId()<1){
        $this->product = Mage::getModel('catalog/product');
        $this->product->setSku($this->actindo['art_nr']);
        $this->newProduct = true;
        $this->product->setAttributeSetId($this->getDefaultAttributeSetId());
        $this->product->setStoreId(Mage::app()->getStore()->getWebsiteId());
        $this->product->setCreatedAt(strtotime('now'));
    }

然后我设置所有必填字段,例如description等

Then I set all the required fields like description etc

和然后我正在做一个存储

and then I'm doing a store

$this->product->save();

产品可以正确显示在管理后端中,但在商店前端中看不到.

The Products appear correctly in the Admin Backend, but they aren't visible in the shop frontend.

我检查了数据库,发现没有写入几个索引. 平面表也不会保存. 如果以后将其再次存储在管理后端中,则将保存所有内容. 我的平板电脑目前处于禁用状态. 但是他们的内容仍然是书面的.

I checked the database and saw that several indexes are not written. Also the flat tables aren't saved. If I store it afterwards again in the admin backend, everything is saved. I have the flat tables currently disabled. But their content is still written.

我正在使用Magento 1.7.0.1,PHP5.3以fpm和Web服务器nginx的身份运行.

I'm using Magento 1.7.0.1 with PHP5.3 runing as fpm and web server nginx.

我也已经尝试重建索引和所有内容,但是在前端仍然不可见. 我究竟做错了什么? 我推送到脚本的所有字段均已写入,并在admin部分中可见. ????

I also already tried to rebuild the indexes and everything, but it still is not visible in the frontend. What am I doing wrong? All fields that I push to the script get written and are visible in the admin section. ????

推荐答案

您可能已经尝试了所有这些方法,但是我知道弄清楚为什么产品未显示"是一个令人沮丧的过程.

you have probably tried all these but I know figuring out 'why is the product not showing' is a frustrating process.

我的建议是尝试在Magento管理区域中手动制作类似的产品,然后检查每种产品在管理区域中的所有字段.您可能会仔细考虑设置'website_ids',我认为store_id和website_id是不同的东西,不是吗? $store_id = Mage::app()->getStore()->getStoreId();$store_website_id = Mage::app()->getStore()->getWebsiteId();

My advice is try making a similar product manually in the Magento admin area and then check all the fields in the admin area for each product. You might look at setting 'website_ids' closely and I think store_id and website_id are different things, no? $store_id = Mage::app()->getStore()->getStoreId(); vs $store_website_id = Mage::app()->getStore()->getWebsiteId();

您还可以使用system-> import/export导出工具来比较Magento设置的内容与算法设置的内容.

You could also use the system->import/export export tool to compare what Magento has set vs what your algorithm is setting.

您是否正在阅读Magento AdminHTML功能以节省产品?

Are you reading the Magento AdminHTML functions for product saving?

    /* path:  app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php */
    Mage_Adminhtml_Catalog_ProductController::saveAction()
    // (and then obviously)
    Mage_Adminhtml_Catalog_ProductController::_initProductSave()
    Mage_Adminhtml_Catalog_ProductController::_initProduct()

因此,查看该代码,如果您可以在手动制作测试产品时单击保存"按钮时从Magento Admin中捕获POST,那么您将能够看到正在传递"到saveAction( )功能,并将其与您的代码进行比较.

So looking at that code, if you can capture the POST from the Magento Admin when you click the save button when you manually make your test product then you will be able to see what is being 'passed in' to the saveAction() function and compare that with your code.

您从哪里运行代码?如果要实例化自己的Mage :: app(),我认为您需要将其设置为管理会话并设置商店ID等.我找不到对此的引用,但是请四处搜索,如果您认为这可能与它有关.也许您可以使用调用saveAction()或重新使用该代码,而不是使用$ this-> product-> save().

Where do you run your code from? If you are instantiating your own Mage::app() I think you need to set it up as an admin session and set store ids and such. I can't find a reference to that but search around if you think that might be something to do with it. Maybe you can use a call to saveAction() or re-purpose that code rather than using $this->product->save().

如果您有一个用于运行任意代码的测试模块,请尝试通过构建不同产品集合进行一些调试调用和回显,以查看生成的产品和手动输入的测试产品之间的区别.

If you have a test module for running arbitrary code, try some debug calls and echos from building different product collections to see what is the difference between your generated product and your manually entered test product.

计划B:如果您有外部产品数据源,则可能会找到最出色的' MAGMI Datapump API "是实现所需目标的最简单,最快的方法.

Plan B : If you have an external product data source, you might find the most excellent 'MAGMI Datapump API' the simplest and quickest way to achieve what you want.

信息太多了吗?

这篇关于Magento不替换已存储的物品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆