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>


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

 

2013/07/30

Magento rule based production relation

今日試用了rule based related product , 在一堆product 加上一個attribute " related product code"

再在rule base product 裏面"product to display" 設定上該attribute

但在frontend 一直call不到product...

磨了良久, 最後發覺condition 設定條件時不能選"is"  , 要選"contains" ....

估計是有space  / trim 空白的問題.......

這不科學啊!

2013/07/22

Magento ce 1.8, ee 1.13 no seo product url after magmi import

新版不再用CORE_URL_WRITE

URL KEY 的TABLE獨立抽出存在

catalog_product_entity_url_key (不可DEL)


之後RUN REINDEX 會把這些RECORD 轉存到
enterprise_catalog_product_
rewrite,

換言之, 若果SKU 不存在於catalog_product_entity_url_key  , 即使REINDEX 完佢亦都不會存於enterprise_catalog_product_rewrite
但問題是經MAGMI IMPORT的產品, 並沒有儲URL KEY到catalog_product_entity_
url_key ...
所以就寫了一段SCRIPT, 把逐個SKU 的URL-KEY INSERT到  catalog_product_entity_
url_key  , 當然是會加上CHECKING, 當不存在此URL-KEY才INSERT


 <code>
<?php
include_once('app/Mage.php');
Mage::app();
echo 'go';
$dbHandle          = Mage::getSingleton('core/resource')->getConnection('core_write');
$productCounter    = 0;
$nameFixCounter    = 0;
$vUrlKeyFixCounter = 0;
$urlPathCounter    = 0;
$urlKeyCounter     = 0;
$productCollection = $dbHandle->query("SELECT entity_id, sku FROM catalog_product_entity where sku not like '%EP' and sku not in (SELECT value FROM catalog_product_entity_url_key ) order by entity_id desc");

$limit =1000000;
$i = 0;
print'<pre>';
while($i<=$limit && $product = $productCollection->fetch()) {
   
    //if (preg_match("/EP/i",$product['sku'])) continue;
   
  $dataString       = null;

  $key_exist   = $dbHandle->query("SELECT value FROM catalog_product_entity_url_key WHERE  entity_id = '".$product['entity_id']."'")->fetch();
 
  if (!empty($key_exist)){
    print_r( $key_exist);
  } else {
 
    //echo 'no - '.$product['sku'];
    //echo '<br/>';
    //INSERT INTO `catalog_product_entity_url_key` (`value_id`, `entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (132441, 4, 97, 0, 1506165, '9789620433139');
    try
    {
        echo 'insert - '. $product['entity_id'];
        $dbHandle->query("INSERT INTO `catalog_product_entity_url_key` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (4, 97, 0, ".$product['entity_id'].", '".$product['sku']."')")
        ->fetch();
       
    }
    catch(Exception $e)
    {
        //echo '<p style="color:red;">'.$e -> getMessage().'</p>';
    }
   
  }
 
 
  $i++;
  }
</code>