我正在使用Magento Community Edition版本.1.6.2.0.
我正在尝试使用Varien Data Collection模型(而不是Api)添加Simple产品.
正在创建产品,但未设置价格,税级ID和重量.
如果有人可以建议为什么没有设置这些特定的产品属性,我将不胜感激.
这是我的代码:
// instatiate Product
$product = Mage::getModel('catalog/product');
$product->setWebsiteIds(array(1));
$product->setSku('99996');
$product->setPrice(99.0000);
$product->setAttributeSetId(4);
$product->setCategoryIds(array(2));
$product->setType('Simple Product');
$product->setName('Product Name6');
$product->setDescription('The Product Description');
$product->setShortDescription('Brief Description');
$product->setStatus(1);
$product->setTaxClassId(2);
$product->setWeight(1.0000);
$product->setCreatedAt(strtotime('now'));
$product->save();
$stockItem = Mage::getModel('cataloginventory/stock_item');
$stockItem->loadByProduct($product->getId());
if (! $stockItem->getId()) {
$stockItem->setProductId($product->getId())->setStockId(1);
}
$stockItem->setData('inventory_manage_stock_default', 1);
$stockItem->setData('is_in_stock', 1);
$stockItem->setData('qty', 10000);
$stockItem->save();
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏!
亲切的问候,
詹姆士
我在注册表单中添加了2个自定义属性,以收集前端客户的输入.
我的问题是来自前端注册表单的数据没有存储在数据库中.
我正在存储管理区域中为这些字段输入的任何数据,但我需要从客户处收集信息.这是我的代码:
app/code/local/Symphony/Khaos/sql/khaos_setup/mysql4-upgrade-0.1.12-0.1.13.php(是的,我试过几次这个权利;))
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute('customer', 'source', array(
'input' => 'text',
'type' => 'varchar',
'label' => 'Where did you hear about us?',
'visible' => 1,
'required' => 0,
'position' => 1,
'sort_order' => 80,
));
$installer->addAttribute('customer', 'practitioner_referrer', array(
'input' => 'text',
'type' => 'varchar',
'label' => 'Referring practitioner',
'visible' => 1,
'required' => 0,
'position' => 1,
'sort_order' => 80,
));
$installer->endSetup();
$customer = Mage::getModel('customer/attribute')->loadByCode('customer', 'source');
$forms= array('customer_account_edit', 'customer_account_create', 'adminhtml_customer', 'checkout_register');
$customer->setData('used_in_forms', $forms);
$customer->save();
$customer …Run Code Online (Sandbox Code Playgroud) 我正在为Laravel应用程序实现一些访问控制逻辑.如果用户无权查看该资源,我想重定向到"未授权"页面.
我正在为我的网址使用控制器/方法逻辑.
我可以从被调用的控制器/方法重定向,但为了使我的代码更具可伸缩性,我想在URI控制器/方法之前检查父控制器中的ACL逻辑,可能是Base_controller,并从那里重定向.访问.
我试图将重定向添加到构造中,或者在重定向的构造中调用另一个方法,但无济于事.
所以,我想知道这是否可行,因为'Redirect :: to'似乎只能在url中指定的控制器/方法中工作,而在其他任何地方 - 这是正确的吗?