Magento Custom Module EAV Attribute Table Unique Key

I created a Magento 1.9.2 module with EAV Table for importing custom data, but when I tried to import second time and update the existing data, it created new entries in Attribute table instead of updating it. I searched for awhile finally figure out that the Setup script won’t create unique key (entity_id, entity_type_id, store_id, attribute_id) for my attributes table.

Although I can just use command to add the unique key, I want to do it inside the setup script. End up it is straight forward.

 

Read More

Creating Magento Custom Module with Entity table

I was writing a Magento module and trying to create a custom entity table for my Model.  However, every time I run the installation script, it just create table with name t_xxxxxxx  (x is random number) and the associate attribute tables.  Took me so long to figure out that my config.xml was wrong with this format:

<entities>
<foo>
<table>
foo_entity
</table>
</foo>
</entities>

Turn out that is not correct. I need to put the table name right after the <table>


<entities>
<foo>
<table>foo_entity</table>
</foo>
</entities>

Then it create a table with name ‘foo_entity’

FML for spending so much time to figure this out.

Read More

Chrome Extension Permission URL pattern is malformed

Today I was learning how to create a Chrome Extension App and I got this warning after I set the permission in manifest.json.

Permission ‘http://192.168.1.100’ is unknown or URL pattern is malformed.

After searching for awhile, I finally figure out that I need to add slash at the end.

“permissions”: [
“http://192.168.1.100/”,
“http://192.168.1.101/”
],

And the warning is gone!

Read More

iOS 9 NSURLConnectionSSL error

Today I was testing an app on iOS9 simulator, and got an Error when connecting to Parse.  After doing some research, I found that there is App Transport Security in iOS9.

For now, I am using couple services, so I have read the quick fix for the App now is to add NSAllowsArbitraryLoads into Info.plist.  Add this to your Info.plist for a quick fix, but you should read the document for a better security.

<key>NSAppTransportSecurity</key>

<dict>

<key>NSAllowsArbitraryLoads</key>

<true/>

</dict>

 

Read More

iOS Popover presentation Segue

popover

This is just a quick guide on how to create a pop over view controller over other view controller with Present As Popover Segue.  

In UI Storyboard, we will create two view controllers.   The first UIViewController we will add a UIButton to active other UIViewController as Pop over, and the other UIViewController will just contains a UILabel.  (I created a class for the pop over view controller as PopOverViewController, but UIViewController will be fine)

popover2

Also, the view controller that will be used as pop over, we will set it to freeform and select your own size in the size inspector.

popover5

 

In Attributes Inspector, also change the Size to Freeform, and no Status Bar.  Select Use Preferred Explicit Size and set the size.

popover6

 

 

Next, we will the connect the button to the pop over controller with popover presentation segue.

Give the segue an Identifier.  In this example, I used “popoverSegue“.

popover3popover4

 

Now, coding time.  In the parent viewcontroller(the one with UIButton), first add a

UIPopoverPresentationControllerDelegate protocol to the class.

then add this:

 

You should be familiar with the first function.  We want to set up the the pop over viewcontroller with style as UIModelPresentationPopover, and set the popoverPresentationController delegate to the parent controller, so that the parent controller will take care the popover viewcontroller presentation style.

Since we don’t want any other style but only pop over style when the segue performs, and the delegate function

adaptivePresentationStyleForPresentationController: 

will do this for us, and tell the APP that we only want the pop over style.

 

Reference: 

https://richardallen.me/2014/11/28/popovers.html

 

 

 

 

 

 

Read More