Thursday, May 28, 2015

import products in magento

https://www.siteground.com/tutorials/magento/import-products.htm

It is rather inconvenient to manually add a large number of products at once to a Magento installation. Inserting products one by one will take a long time especially when you have hundreds or thousands of products.In such cases you need an automatic way to add all those products to your Magento online store. We will address all steps you need to take in order to achieve a successful import.
First, access your Magento administrator backend and go to Catalog -> Manage Categories.
Create all product categories you will need. You can do so by filling the form displayed below:
When you fill the form with all the information you like click the Save Category button.
Bear in mind that at this point you should make note of the newly created category ids. It would be best to save them in a simple text file as you will need them for the import. The category ID will be displayed upon saving the category. It is recommended to make notes as shown below
If you plan to have additional attributes for the products you are importing you will need to create those via Catalog ->Attributes ->Manage Attributes -> Add new Attribute. You can use this functionality to add all custom attributes that are not present by default in a standard Magento installation. Note also that you can add additional attributes later at the moment you are creating a sample product. It is up to you whether to create the attributes before that or at the point you are creating the first product.
The next step is to manually add a product to your Magento installation. You will later export this product and use it as a template for importing the large batch. Make sure you include all attributes you will use for the products you are going to import in the sample product. You might want to delete all default products that might be present as you will not need them and then create the new product you will use as a template for the import.
Once you create the new product and save it it will appear in the products list for your Magento store.
You are now ready to make the sample export that you will use as a template. In the Magento administrator area go to System -> Import/Export -> Dataflow - Profiles -> Export All Products. Under Profile Information -> Store choose the desired store where you will be importing the products. This should also match the store where you have previously created a sample product. Under Data Transfer drop down menu choose Local/Remote Server. Under Data Format make sure CSV / Tab Separated is selected for type and click Save Profile. Then click export all products again and click Run Profile in Popup.
This will save a file named “export_all_products.csv” under the var/export/ directory for your Magento installation. The export success screen will look like this and will specify the file name where the products were exported.
Using an FTP client download this file to your local computer. The file will include columns for each of the attributes you have defined for your products. Open it in a spreadsheet program (MS Excel, Open Office Spreadsheet) and add the products you would like to import. Make sure you are copy/pasting the corresponding attributes in the correct columns. Also here is when you will have to add the category IDs. Use the IDs from the text file you saved earlier and put the corresponding category ID for the products you are adding.
Once you have accomplished the above go back to the Magento administrator area and choose System -> Import/Export -> Dataflow - Profiles -> Import All Products. Then choose Upload file and browse for the .csv file that you have updated with the products that need to be imported. Once you have uploaded it click Import All Products again, then Run Profile, select the .csv file you have just uploaded from the drop down menu and click Run Profile in Popup. A status screen will open and the products will start importing
When the import completes you will get an export success message.
You can now go to the products section of the Magento administrator backend and check the imported products. They will be present there and assigned to the corresponding categories with the attributes you have added for them.

Magento bulk product import with images


http://www.mootpoint.org/blog/magento-bulk-product-import-images/

Magento bulk product import with images


I recently had to transfer the inventory of an old Shop Factory site into Magento 1.7. Magento offers a powerful facility to do this via CSV using its DataFlow profiles but this is not without its quirks and pitfalls so I thought I’d share my experiences.

Importing product data

First, you will need to know the data format required by Magento for import. The simplest way to do this is to create a sample product in Magento and export all products. To do this:
  1. Go to System > Import/Export > DataFlow – Profiles
  2. Edit the Export All Products profile and Run Profile
The exported CSV file will be placed in the /var/export folder. You will need to FTP into your Magento hosting to retrieve the file.
Open this file in a spreadsheet application. I used OpenOffice Calc as it allows the CSV to be saved as UTF-8 which is required by Magento. The first row shows the product field names required by Magento – for your first import, you will need all these fields to be present, even if the values are blank. Copy and paste the columns of data from the CSV exported from your old inventory into the Magento CSV. You don’t need all the columns, if in doubt just leave them with the same values as your sample product. The values you must have are:
  • sku – this is the unique product ID and is used by Magento to allocate the data to the correct product in its database. Any subsequent imports with the same sku will update the data. I didn’t have unique skus from my previous inventory so I created them using the product names converted to lowercase and with spaces replaced by hyphens.
  • type – this must be set. I used “simple”.
  • category_ids – these will need to be mapped from your old categories to the new categories in Magento. You can look up the Magento category IDs in Catalog > Manage Categories by clicking on the category – the ID will be shown at the top. If you have a lot of categories like I did, you can export them from phpMyAdmin using the following SQL query:
    SELECT ccev.entity_id AS categoryID, cce.path, ccev.value FROM catalog_category_entity cce JOIN catalog_category_entity_varchar ccev ON ( cce.entity_id = ccev.entity_id )  GROUP BY ccev.entity_id ORDER BY path
    I then placed these values in a separate spreadsheet, and manually entered the corresponding old category ID in the next column. Now I could use Calc’s LOOKUP function to map each old category ID to the new one in the Magento CSV. This saved a lot of time when making changes to category allocations, and also prevented me having to manually enter the new category IDs for each product.
  • image, small_image, thumbnail – leave these blank. It’s better to import the images separately (see below) because Magento will not import the product if it can’t find the referenced image (for instance if the image filename is wrong).
Once you have all your product data in the correct columns, save the spreadsheet as a CSV, making sure to use quotes around text fields and to save in UTF-8.
Now you can import the product data by running the Import All Products DataFlow profile. Upload your edited CSV and run the profile. It’s pretty slow, taking about a second a product, so now may be a good time for a cup of tea.

Importing product images

Now that your products exist in the Magento database, you can perform a separate import to attach your images to the products.
  1. First, FTP your product images to the /media/import folder of your Magento installation. Magento will resize your images to the correct dimensions on import, so just upload the best quality image you have for each product.
  2. Create a new spreadsheet with the following columns: sku, image.
  3. Copy the sku column from your product data CSV.
  4. Copy the image filenames from your old inventory export to the image column. The filenames should have the format:
    /.jpg
    (note the leading slash).
  5. Save the CSV as import-product-images.csv in UTF-8.
  6. Create a new DataFlow profile called Import Product Images with the following settings:
    • Entity Type: Products
    • Direction: Import
    • Data Transfer: Interactive
    • Type: CSV/Tab Separated
    • Field Mapping: sku > sku, image > image
  7. Upload your import-product-images.csv and Run Profile.
Voila! Your products should now have images.

Notes

Magento DataFlow does not have very helpful error messages, for example it will tell you “Image not found” but not tell you which image. The mysterious “Product type not set” message is probably because a text field is not enclosed in quotes.

Removing duplicate images

Every time you run a product image import, Magento copies the image from /media/import into a subdirectory of the /media/catalog/product folder. Annoyingly, it does not replace the image but rather adds it to the product and creates a copy _2.jpg etc. So after several imports, you will have several copies of each image in your media folder and duplicate images on each product. You can remove the duplicate images from the product data with this script, and delete unused duplicate images with this extension. However, when importing the complete catalog several times, I found it simpler to:
  • Delete the /media/catalog/product folder.
  • Delete the product image references in the Magento database using the following SQL:
    DELETE FROM catalog_product_entity_media_gallery
    DELETE FROM catalog_product_entity_media_gallery_value
Be warned! Only do this to clear all product images and start again.
Once you have successfully imported all images, you can safely delete any images in /media/import to free up server space.

Wednesday, May 20, 2015

iTunes Connect - No Beta Entitlement - Phonegap Build

http://stackoverflow.com/questions/30119170/itunes-connect-no-beta-entitlement-phonegap-build



it's caused by the provisioning profile. I changed from ad hoc provisioning profile to apple store provisioning profile and it worked.

Sunday, April 19, 2015

Resolving The Infamous Magento Deleting Issue (SQLSTATE[22003]: Numeric value out of range: 1690 BIGINT UNSIGNED value is out of range in ‘(`YOURDBNAME`.`q`.`items_count` – 1)

From :

https://www.golocalexpert.com/resolving-the-infamous-magento-deleting-issue-sqlstate22003-numeric-value-out-of-range-1690-bigint-unsigned-value-is-out-of-range-in-yourdbname-q-items_count-1/


Project Fix:

I recently had to resolve this issue for a customer, and since it was quite easy to fix, I figured I’d share with all you developer and do it yourselfers.

Error Message:
SQLSTATE[22003]: Numeric value out of range: 1690 BIGINT UNSIGNED value is out of range in ‘(`YOURDBNAME`.`q`.`items_count` – 1)’

How to Fix:
  1. Go into your database using PhpMyAdmin.
  2. Do a backup (always a good practice to back-up first).
  3. Select the Magento database you’re using.
  4. Select table sales_flat_quote (on second page).
  5. Select structure tab
  6. Select ‘change‘ on row called ‘items_count
  7. Go to the drop-down on the column named ‘Attributes‘ and change value to the very top value which is blank ‘(no value)‘, as opposed to the default selection ‘UNSIGNED‘ .
  8. Click save, and you’re good to go!
You should now be able to delete your products with no more error. This would have costed you at least $200 dollars, my complements to you all for free.

Magento Version 1.9.0.1


Monday, May 26, 2014

How to Transfer Magento

http://www.siteground.com/tutorials/magento/magento_move.htm


Backup the Magento MySQL Database

On SiteGround servers you have phpMyAdmin included by default in cPanel for your account. In other cases you will have to use the same tool or a similar one that is capable of exporting your MySQL database. Detailed information on how to perform a MySQL backup can be found in our MySQL Tutorial.
Alternatively, if you don’t have phpMyAdmin installed but you have shell access you can use the mysqldump tool. The syntax is as follows:
mysqldump -h HOST -u USER -p DATABASENAME > FILENAME.sql
where:
  • HOST is the database server hostname or it can be omitted if you are running the MySQL server locally
  • USER - a user with full privileges to the Magento database
  • DATABASENAME - is the full name of the database which Magento is running
  • FILENAME - can be anything you find suitable for the backup file
Also, if you have Plesk, DirectAdmin or any other web hosting management tool, you can look at the available options. Many panels allow you to dump the database with just a few clicks. For example cPanel does have an option for this.

Step 2 Transfer all Magento Files

You will need to download all files from your current store and upload them to the new location. This can be a time consuming task considering that a standard Magento installation consists of many files. A good alternative is to archive the files prior to downloading/uploading them if possible.
If you have SSH access you can log on your server -> magento installation directory and archive all the files using the following command:
tar -czif ARCHIVENAME.tar.gz
This will create a tarball archive of all the files in the directory.
You can then download the archive and easily upload it to the new location. To extract it at the new location use the following command in the desired destination folder for the Magento installation:
tar -xzif ARCHIVENAME.tar.gz

Step 3 Adjust the Magento Configuration

After the files are restored you should alter the configuration file in order to match the new settings. All you need to change here is the database details at the new location. Those are stored in the app/etc/local.xml file. The lines you need to alter are:
<![CDATA[HOSTNAME]]><![CDATA[USER]]><![CDATA[PASSWORD]]><![CDATA[DATABASENAME]]>
where:
  • HOSTNAME should be the database hostname, most commonly - localhost
  • USER is a user that has full privileges to the database
  • PASSWORD is the password for the database user
  • DATABASENAME is the complete database name for the database you are going to use with the transferred Magento

Step 4 Restore the Magento Database

Once you have adjusted the options above you should restore the database at the new location.
A good practice is to add several options in the MySQL backup file prior to uploading it. The following should be added at the beginning of the SQL file:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT;SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;SET NAMES utf8;SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;
The next option should be added at the end of the file after all other queries:
SET SQL_MODE=@OLD_SQL_MODE;SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT;SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS;SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION;SET SQL_NOTES=@OLD_SQL_NOTES;
You can now import the database using phpMyadmin -> Import or another MySQL tool depending on what kind of access you have to the website.
In case you would like to restore the database via a shell command you can use the following:
mysql -h HOST -u USER -p DATABASENAME < FILENAME.sql
and enter the password for the database user when asked.
Note that if the Magento online store is supposed to work with a different domain name at the new location you should alter the entries for it in the MySQL database.
The table you should edit is core_config_data and the values you need to change are in the path column. Change the web/unsecure/base_url and web/secure/base_url to match the new domain name by altering the value column for both records.


The last step is to clear the Magento cache. You can do this either via the Magento admin panel > System > Cache management or by deleting the contents of the var/cache and var/session folders inside your Magento installation directory.

That is all. Your Magento should now be properly functioning at the new location.

Wednesday, October 23, 2013

MVC CREATE DATABASE permission denied in database 'master'.

MVC

CREATE DATABASE permission denied in database 'master'.

For my case, I need to stop and disable the sqlexpress service.



Insufficient Permissions

Another common problem I’ve seen popping up when using Code First migrations is typically realized with one of the following exceptions:
System.Data.SqlClient.SqlException: Login failed for user ‘[Your account here]'.
... and ...
System.Data.SqlClient.SqlException (0x80131904): CREATE DATABASE permission denied in database 'master'.
These permission issues can be hard to fix. The first thing I’d do is add some debugging code to verify the connection string being used by the Entity Framework (the debugging code demonstrated earlier). Once you know the server the Entity Framework is trying to reach you should try to login to the server with a management tool (like SQL Management Studio, which also works with LocalDb), if you can. The problem is you might not be able to login with your account.
Even if you are an administrator on your local machine you might find yourself with limited privileges in your own, local SQL Server. One scenario where this can happen is when SQL Server or SQL Server Express is installed onto your machine by a different user, or you installed the software using a different account, or perhaps your machine was built from a cloned image file. As of SQL 2008, just being an administrator in Windows doesn’t make you a sysadmin in SQL Server.
To fix the permission issues you can try to login to the server using the sa account, but of course you must know the password and the sa account must be enabled. You can also try to login to your machine using the Windows account used for the software installation. Once logged in with high privileges you’ll need to add your Windows login to the list of SQL Server logins and (ideally) put yourself in the sysadmin server role.

When all else fails, you can try to regain control of SQL Server by starting the server in single user mode (see Connect to SQL Server When System Administrators Are Locked Out). The SQL Express blog also published a script to automate this process (see How to take ownership of your local SQL Server), which should also work with SQL 2012. The nuclear option, if you don’t care about any of the local databases, is to uninstall and reinstall SQL Server.



http://odetocode.com/Blogs/scott/archive/2012/08/14/a-troubleshooting-guide-for-entity-framework-connections-amp-migrations.aspx

Sunday, February 10, 2013

Create dll libary include with ascx or aspx

Building Re-Usable ASP.NET User Control and Page Libraries with VS 2005 

http://weblogs.asp.net/scottgu/archive/2005/08/28/423888.aspx

 

Turning an .ascx User Control into a Redistributable Custom Control

http://msdn.microsoft.com/en-us/library/aa479318.aspx

 

Background

Since its early days, ASP.NET has always supported two different ways of authoring server controls:
  1. Custom controls: These are controls written from scratch exclusively using code. Essentially, you write a class that extends Control (directly or indirectly), and you take care of everything. You need to write logic to create child controls that you want to use, and you override the Render method to perform rendering. Typically, you build this control into a redistributable assembly (that is, a DLL), which can then be used by any ASP.NET applications, simply by placing the assembly in the "bin" directory of the application (or in the Global Assembly Cache).
  2. User controls: These controls are written using an .ascx file, which looks much like an aspx page. That is, you can simply drag and drop the UI elements that you want to use into the design surface. You don't need to worry about control creation, nor about overriding the Render method.
These two methods are very different, and each has a number of advantages and disadvantages. I won't discuss them all, but will focus on those that are relevant to this article:
  • Custom controls require a lot of development expertise to be written, while user controls are authored using an advanced designer, and are much more approachable. For this reason, user controls typically take a lot less time to write.
  • Custom controls can easily be redistributed without having to give away their sources. On the other hand, user controls are always used based on an ascx text file, making it less ideal for reuse across applications.
The goal of this article is to show how you can have the best of both worlds by turning an ascx user control into a redistributable custom control, by making use of the new ASP.NET precompilation features.

Brief Outline of the Steps

The basic steps to make this happen are as follows:
  1. Write your user control as you normally would, typically using the Visual Studio designer.
  2. Test it using a simple page before trying to deploy it.
  3. Deploy the application to precompile it.
  4. Grab the user control's assembly produced by the deployment step, and you're essentially done: You have your custom control.
  5. Finally, use your custom control in other apps the same way as you always use custom controls.
We will look at those steps in more detail in the rest of the article.

Step 1: Authoring the User Control

To author the user control, it is best to start with an empty app that contains nothing other than the ascx. While the authoring of the user control uses "standard" techniques, there are some restrictions that you need to be aware of in order for it to be successfully turned into a standalone custom control.
The main restriction is that the user control needs to be self-contained. That is, it cannot be dependent on app global things like App_Code or global.asax. The reason for this is that since the goal is to turn the UserControl into a standalone DLL, it would break in other apps if it relied on code that is not part of that DLL. One exception to this rule is that the UserControl can be dependent on assemblies that live in the bin directory (or in the GAC). You just have to make sure that the other assemblies are always available when you use your custom control in other apps.
Another tricky thing is the use of static resources, such as images. After you turn it into a custom control in a standalone assembly, it becomes hard for it to keep such references, and avoiding them simplifies deployment. If you really must have such references, one option is to use absolute URLs if you can guarantee that the resource will always be available on a certain site. Or you can look into machine wide resources (e.g., src="/MyImages/welcome.jpg"), though you will then need to make sure the resources are installed on the server machine (e.g. as part of some setup).
So let's start and actually author the user control. Visual Studio 2005 gives you the choice to place the code in a separate file, or use inline code. This is a matter of personal preference, and either one will work to create a custom control. For this article, we will use inline code. When you create the user control (say MyTestUC.ascx), Visual Studio creates it with the a @control directive that looks like this:
<%@ControlLanguage="C#"ClassName="MyTestUC"%> 

This is fine, except for one thing: we want the class to live within a namespace of our choice (instead of "ASP", which is used by default). To do this, we simply modify the ClassName attribute to include the namespace (this is a new feature in 2.0). Here's an example:
<%@ControlLanguage="C#"ClassName="Acme.MyTestUC"%> 

That's really the only "special" thing you need to do. Now you can go ahead and implement your user control as you always would: add some server control, some client HTML, server script, client script, and so on.

Step 2: Testing Your User Control

Before trying to turn the user control into a custom control, it is a good idea to test it in the source app using a simple page. To do this, simply create a new Page in Visual Studio, go to design View, and drag and drop your user control into it.
The two notable pieces of your page are the Register directive:
<%@RegisterSrc="MyTestUC.ascx"TagName="MyTestUC"TagPrefix="uc1"%>
and the user control declaration:

Note that at this point, the Register directive uses the user control syntax (Src/TagName/TagPrefix) and not the custom control syntax (TagPrefix/Namespace/Assembly). This will change after we turn the user control into a custom control.
Run your page (press CTRL-F5) and make sure the user control works the way you want before moving to the next step.

Step 3: Use the Publish Command to Precompile the Site

The next step is to use the new Publish command to precompile your site and turn your user control into a potential custom control. You'll find the command under Build / Publish Web Site. In the Publish dialog, do the following:
  • Pick a Target Location. This is the location on your hard drive that your site will be precompiled to.
  • Deselect "Allow this precompiled site to be updatable". In updatable mode, only the code behind file (if any) would get compiled, and the ascx would be left unprocessed. This is useful in some scenarios, but is not what you want here since you want the resulting DLL to be self-contained.
  • Select "Use fixed naming and single page assemblies". This will guarantee that your user control will be compiled into a single assembly that will have a name based on the ascx file. If you don't check this option, your user control could be compiled together with other pages and user controls (if you had some), and the assembly would receive a random name that would be more difficult to work with.
Though it is entirely optional, note that the Publish Web Site dialog lets you strongly name the generated assemblies. This allows you to sign the assembly so that it cannot be tampered with. Additionally, it allows you to place the assemblies in the Global Assembly Cache (GAC), which makes it easier to use machine-wide. I will provide more information on this in Step 5.
Go ahead and complete the dialog, which will perform the precompilation.
Note   This same step can also be accomplished without using Visual Studio by using the new aspnet_compiler.exe command-line tool. The options it supports are basically the same as what you see in the Publish dialog. So if you are more command-line inclined, you might prefer that route. For example, you would invoke it using the command:
aspnet_compiler -p c:\SourceApp -v myapp -fixednames c:\PrecompiledApp
.

Step 4: Finding the Resulting Custom Control

Now, using the Windows Explorer or a command-line window, let's go to the directory you specified as the target so we can see what was generated. You will see a number of files there, but let's focus on the one that is relevant to our goal of turning the user control into a custom control.
In the "bin" directory, you will find a file named something like App_Web_MyTestUC.ascx.cdcab7d2.dll. You are basically done, as this file is your user control transformed into a custom control! The only thing that's left to do is to actually use it.
Note   In case you're curious, the hex number within the file name (here
cdcab7d2
) is a hash code that represents the directory that the original file was in. So all files at the root of your source app will use
cdcab7d2
, while files in other folders will use different numbers. This is used to avoid naming conflicts in case you have files with the same name in different directories (which is very common for default.aspx!).

Step 5: Using Your New Custom Control

Now that we have created our custom control, let's go ahead and use it in an app. To do this, create a new Web application in Visual Studio. We then need to make our custom control available to this application:
  • In the solution explorer, right-click on your application, and choose Add Reference.
  • In the Add Reference dialog, choose the Browse tab.
  • Navigate to the location of your custom control (App_Web_MyTestUC.ascx.cdcab7d2.dll) and select it. It will be copied to the bin directory of your new app.
Note   as an alternative, you can choose to place the assembly in the GAC instead of the "bin" directory. In order to do this, you need to choose the Strong Name option in Step 3. You then need to add your assembly in the section of web.config in the Web application that requires it (or in machine.config to make to globally usable).
Create a test page that uses the custom control. This is similar to Step 2, except that you are now dealing with a custom control instead of a user control.
First, add a Register directive to your page. It should look something like this:
<%@RegisterTagPrefix="Acme"Namespace="Acme"Assembly="App_Web_mytestuc.ascx.cdcab7d2"%> 
Note how we are using a different set of attributes compared to Step 2. Recall that in Step 1, we made sure that the ClassName attribute included a namespace. This is where it becomes useful, as custom control registration is namespace-based. Also, you need to specify the assembly name, which is why having a name that is easily recognizable is useful, as discussed in Step 3.
Declare a tag for the custom control, for example:
 
That's it, you can now run your app (CTRL-F5), and you are using your new custom control!
This shows how to use your custom control declaratively, but note that it can also be used dynamically, just like any other control. To do this, just create the control using "new". Here is what the previous sample would look like using dynamic instantiation:
<%@PageLanguage="C#"%>








Note   Instantiating your custom control dynamically as described above is basically the equivalent of instantiating your original user control using the LoadControl API. Note that you can no longer use the standard LoadControl API after converting it to a custom control, since custom controls don't have a virtual path. However, ASP.NET 2.0 has a new LoadControl override that takes a Type that you could use in this case. The one reason I can think of that you might choose to call LoadControl instead of just using "new" is to take advantage of fragment caching (also called partial caching). If you use "new", any OutputCache directive in your ascx will be ignored.