Programming language e.g. PHP, JAVASCRIPT, coding, web developing hints and skills applying on mobile device e.g. iphone
2014/02/19
Cannot update qty after clearing magento db
f you failed to create a new product from admin and you’ll get an error message something like this
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`cataloginventory_stock_item`, CONSTRAINT `FK_CATALOGINVENTORY_STOCK_ITEM_STOCK` FOREIGN KEY (`stock_id`) REFERENCES `cataloginventory_stock` (`stock_id`) ON DELETE CASCADE ON UPDATE)
You have to check whether you deleted entry from cataloginventory_stock table. If yes then please use below query to add new product.
INSERT INTO cataloginventory_stock SET stock_name = ‘Default’;
for product link
insert into `catalog_product_link_type`(`link_type_id`,`code`) values (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
insert into `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) values (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
insert into `cataloginventory_stock`(`stock_id`,`stock_name`) values (1,'Default');
2014/01/06
magento sql 常用用法
$resource = Mage::getSingleton('core/resource');
$tableName_votes = $resource->getTableName('jselfless/votes');
$tableName_image = $resource->getTableName('jselfless/image');
$collection = Mage::getModel('jselfless/woman')->getCollection();
$collection->getSelect()->reset(Zend_Db_Select::COLUMNS);
$collection->getSelect()->columns(array('items_count'=>'count(main_table.id)'));
$collection->addFieldToFilter('main_table.year',date('Y'));
$collection->addFieldToFilter('image.type','main');
$collection->addFieldToFilter('award',array('eq'=>''));
$collection->getSelect()->join(array('votes' => $tableName_votes), 'main_table.id = votes.selfless_woman_id', '');
$collection->getSelect()->join(array('image' => $tableName_image), 'main_table.id = image.selfless_woman_id', array('image.*'));
$collection->getSelect()->group('main_table.id');
$collection->getSelect()->Order('items_count desc');
$collection->getSelect()->Order('votes.created_at desc');
$collection->getSelect()->Order('main_table.updated_at desc');
$collection->getSelect()->limit(10,$postData['offset']);
2013/11/04
Cannot find the ACL permission in the permission list
In my custom module, i have created the adminhtml.xml for it.
However in the system > permission , i cannot find the checkbox that allows me to assign permission to the user.
After exploring the xml, i found that i was missing <title> tag between the section node and the <children> node.
For the build-in section, e.g. <report>, we can skip the <title> tag because it will load the default value that magento assign to it.( anyway you can still add it to override the default one)
However in my case, <suepreport> is a custom new tag, so i must specify the <title> tag for it!
After adding the title tag, i finally see it in the admin permission tree! Great!
adminhtml.xml
<acl>
<resources>
<admin>
<children>
<report>
<children>
<suepreport>
<title>Suep Report</title>
<children>
<pickuplocationbyshopbrand translate="title" module="suep">
<title>Pickup Location Report- By Shop Brand</title>
</pickuplocationbyshopbrand>
<pickuplocationbyshop translate="title" module="suep">
<title>Pickup Location Report - By Shop</title>
</pickuplocationbyshop>
<monthlyaffiliate translate="title" module="suep">
<title>Monthly Affiliate Report</title>
</monthlyaffiliate>
</children>
</suepreport>
</children>
</report>
</children>
</admin>
</resources>
</acl>
However in the system > permission , i cannot find the checkbox that allows me to assign permission to the user.
After exploring the xml, i found that i was missing <title> tag between the section node and the <children> node.
For the build-in section, e.g. <report>, we can skip the <title> tag because it will load the default value that magento assign to it.( anyway you can still add it to override the default one)
However in my case, <suepreport> is a custom new tag, so i must specify the <title> tag for it!
After adding the title tag, i finally see it in the admin permission tree! Great!
adminhtml.xml
<acl>
<resources>
<admin>
<children>
<report>
<children>
<suepreport>
<title>Suep Report</title>
<children>
<pickuplocationbyshopbrand translate="title" module="suep">
<title>Pickup Location Report- By Shop Brand</title>
</pickuplocationbyshopbrand>
<pickuplocationbyshop translate="title" module="suep">
<title>Pickup Location Report - By Shop</title>
</pickuplocationbyshop>
<monthlyaffiliate translate="title" module="suep">
<title>Monthly Affiliate Report</title>
</monthlyaffiliate>
</children>
</suepreport>
</children>
</report>
</children>
</admin>
</resources>
</acl>
2013/10/07
SQLSTATE[23000] Duplicate entry 'xxx' for key 'PRIMARY'
Problem:
When saving related product, it shows an error :
magento SQLSTATE[23000] Duplicate entry '959' for key 'PRIMARY'
Reason:
yes it right, the key is really duplicate in the table
after checking the related product table --- catalog_entity_product_link, the auto increment of 'link_id' is 950 but the latest record is '959', and it doesnt make sense
Solution:
(1) increase the auto increment to 959 , SET AUTO_INCREMENT = 959
or
(2) delete the record after 950, and then save these related product again
訂閱:
文章 (Atom)